ref: da0cb476f782da72ecd88bf6e9ddca36028620f4
parent: 300897e46abe1ccc337ebc7b2d5f3916c027c6ef
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Mar 12 13:44:33 EDT 2015
pemencode: handle base64 input length < 3, fix bogus zero termination
--- a/sys/src/cmd/auth/pemencode.c
+++ b/sys/src/cmd/auth/pemencode.c
@@ -48,11 +48,11 @@
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);--
⑨