Skip to content

Commit 7d4a646

Browse files
committed
Merge branch 'fix-b64-zero-length-array' into develop
Closes #538
2 parents 2302a3a + 9183396 commit 7d4a646

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/misc/base64/base64_decode.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ static const unsigned char map_base64[256] = {
4242
255, 255, 255, 255 };
4343
#endif /* LTC_BASE64 */
4444

45-
static const unsigned char map_base64url[] = {
4645
#if defined(LTC_BASE64_URL)
46+
static const unsigned char map_base64url[] = {
4747
255, 255, 255, 255, 255, 255, 255, 255, 255, 253, 253, 255,
4848
255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
4949
255, 255, 255, 255, 255, 255, 255, 255, 253, 255, 255, 255,
@@ -66,8 +66,8 @@ static const unsigned char map_base64url[] = {
6666
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
6767
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
6868
255, 255, 255, 255
69-
#endif /* LTC_BASE64_URL */
7069
};
70+
#endif /* LTC_BASE64_URL */
7171

7272
enum {
7373
insane = 0,
@@ -127,7 +127,9 @@ static int s_base64_decode_internal(const char *in, unsigned long inlen,
127127

128128
if (y != 0) {
129129
if (y == 1) return CRYPT_INVALID_PACKET;
130-
if (((y + g) != 4) && (mode == strict) && (map != map_base64url)) return CRYPT_INVALID_PACKET;
130+
#if defined(LTC_BASE64)
131+
if (((y + g) != 4) && (mode == strict) && (map == map_base64)) return CRYPT_INVALID_PACKET;
132+
#endif /* LTC_BASE64 */
131133
t = t << (6 * (4 - y));
132134
if (z + y - 1 > *outlen) return CRYPT_BUFFER_OVERFLOW;
133135
if (y >= 2) out[z++] = (unsigned char) ((t >> 16) & 255);

0 commit comments

Comments
 (0)