diff options
author | Matt Johnston <matt@ucc.asn.au> | 2020-06-26 21:07:34 +0800 |
---|---|---|
committer | Matt Johnston <matt@ucc.asn.au> | 2020-06-26 21:07:34 +0800 |
commit | 71b4ec569cb33a5dcd4abf50650ccd78e6d3b2dd (patch) | |
tree | 497adde943fd41206f8d263131b255dda1833ca1 /libtomcrypt/src/misc/base64/base64_decode.c | |
parent | 3187f27fcd533b8d16feebba9090007c82725eff (diff) | |
parent | eaf9be05d7d9de22f2ff936882874331fc2d1a0e (diff) | |
download | dropbear-71b4ec569cb33a5dcd4abf50650ccd78e6d3b2dd.tar.gz |
merge coverity from maincoverity
Diffstat (limited to 'libtomcrypt/src/misc/base64/base64_decode.c')
-rw-r--r-- | libtomcrypt/src/misc/base64/base64_decode.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libtomcrypt/src/misc/base64/base64_decode.c b/libtomcrypt/src/misc/base64/base64_decode.c index 4c58c68..c1d3c80 100644 --- a/libtomcrypt/src/misc/base64/base64_decode.c +++ b/libtomcrypt/src/misc/base64/base64_decode.c @@ -43,8 +43,8 @@ static const unsigned char map_base64[256] = { 255, 255, 255, 255 }; #endif /* LTC_BASE64 */ -static const unsigned char map_base64url[] = { #if defined(LTC_BASE64_URL) +static const unsigned char map_base64url[] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, @@ -67,8 +67,8 @@ static const unsigned char map_base64url[] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 -#endif /* LTC_BASE64_URL */ }; +#endif /* LTC_BASE64_URL */ enum { relaxed = 0, @@ -117,8 +117,14 @@ static int _base64_decode_internal(const unsigned char *in, unsigned long inlen } if (y != 0) { + int allow_b64url = 0; +#ifdef LTC_BASE64_URL + if (map == map_base64url) { + allow_b64url = 1; + } +#endif if (y == 1) return CRYPT_INVALID_PACKET; - if ((y + g) != 4 && is_strict && map != map_base64url) return CRYPT_INVALID_PACKET; + if ((y + g) != 4 && is_strict && !allow_b64url) return CRYPT_INVALID_PACKET; t = t << (6 * (4 - y)); if (z + y - 1 > *outlen) return CRYPT_BUFFER_OVERFLOW; if (y >= 2) out[z++] = (unsigned char) ((t >> 16) & 255); |