diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-03-12 17:44:33 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-03-12 17:44:33 +0100 |
commit | e437b1b289354c9d390b400f1c9c215857848126 (patch) | |
tree | 677f8a394707ee0f478c2efefe5da4ceb4be80de /sys/src | |
parent | 757354dac6d55d12f28a3a94c601e625cf89c5ac (diff) |
pemencode: handle base64 input length < 3, fix bogus zero termination
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/cmd/auth/pemencode.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/src/cmd/auth/pemencode.c b/sys/src/cmd/auth/pemencode.c index b6e886fa5..24df22cf4 100644 --- a/sys/src/cmd/auth/pemencode.c +++ b/sys/src/cmd/auth/pemencode.c @@ -48,11 +48,11 @@ main(int argc, char **argv) break; tot += n; } - buf[tot] = 0; - cbuf = malloc(2*tot); + len = 2*tot+3; + cbuf = malloc(len); if(cbuf == nil) sysfatal("malloc: %r"); - len = enc64(cbuf, 2*tot, (uchar*)buf, tot); + len = enc64(cbuf, len, (uchar*)buf, tot); print("-----BEGIN %s-----\n", tag); while(len > 0){ print("%.64s\n", cbuf); |