diff --git a/src/misc/base64/base64_decode.c b/src/misc/base64/base64_decode.c index 58591114e..20a9ef3ef 100644 --- a/src/misc/base64/base64_decode.c +++ b/src/misc/base64/base64_decode.c @@ -42,8 +42,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, 253, 253, 255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 255, 255, 255, @@ -66,8 +66,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 { insane = 0, @@ -127,7 +127,9 @@ static int s_base64_decode_internal(const char *in, unsigned long inlen, if (y != 0) { if (y == 1) return CRYPT_INVALID_PACKET; - if (((y + g) != 4) && (mode == strict) && (map != map_base64url)) return CRYPT_INVALID_PACKET; +#if defined(LTC_BASE64) + if (((y + g) != 4) && (mode == strict) && (map == map_base64)) return CRYPT_INVALID_PACKET; +#endif /* LTC_BASE64 */ t = t << (6 * (4 - y)); if (z + y - 1 > *outlen) return CRYPT_BUFFER_OVERFLOW; if (y >= 2) out[z++] = (unsigned char) ((t >> 16) & 255);