Skip to content

Commit

Permalink
Merge branch 'fix-b64-zero-length-array' into develop
Browse files Browse the repository at this point in the history
Closes #538
  • Loading branch information
sjaeckel committed Aug 18, 2024
2 parents 2302a3a + 9183396 commit 7d4a646
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/misc/base64/base64_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7d4a646

Please sign in to comment.