From: Tollef Fog Heen Date: Mon, 19 Oct 2009 13:20:16 +0000 (+0200) Subject: Don't rely on strings being null-terminated. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70b34db7ea8327eb7746ba978ed237a5cd2a39d0;p=yubikey-server-c Don't rely on strings being null-terminated. --- diff --git a/src/util.c b/src/util.c index 7e856cf..4ae2523 100644 --- a/src/util.c +++ b/src/util.c @@ -114,7 +114,9 @@ static void ysc_b64_encodeblock(unsigned char in[3], unsigned char out[4], int l out[0] = cb64[in[0] >> 2]; out[1] = cb64[((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4)]; out[2] = (unsigned char) (len > 1 ? cb64[((in[1] & 0x0f) << 2) | - ((in[2] & 0xc0) >> 6)] : '='); + (len > 2 ? + ((in[2] & 0xc0) >> 6) : + 0 )] : '='); out[3] = (unsigned char) (len > 2 ? cb64[in[2] & 0x3f] : '='); }