Commit c1dc185c authored by Nils Goroll's avatar Nils Goroll

fix buffer size check in base64_encode()

parent 4aa14a09
......@@ -91,9 +91,14 @@ base64_encode(const enum encoding enc, char *restrict const buf,
AN(alpha);
if (in == NULL || inlength == 0)
return 0;
if ((enc != BASE64URLNOPAD && buflen < base64_encode_l(inlength))
|| buflen < base64nopad_encode_l(inlength))
if ((enc == BASE64URLNOPAD &&
buflen < base64nopad_encode_l(inlength)) ||
(enc != BASE64URLNOPAD &&
buflen < base64_encode_l(inlength))) {
errno = ENOMEM;
return -1;
}
while (end - in >= 3) {
*p++ = alpha->b64[(in[0] >> 2) & 0x3f];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment