From 62e1563fa6958fca11221c78833dbad84e03a418 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Tue, 14 Apr 2020 19:11:08 -0400 Subject: [PATCH] Ensure b64Cursor chars are unsigned when used as index. --- platform-independent/c/core/src/base64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform-independent/c/core/src/base64.c b/platform-independent/c/core/src/base64.c index bdb886e6..fccacc6d 100644 --- a/platform-independent/c/core/src/base64.c +++ b/platform-independent/c/core/src/base64.c @@ -81,7 +81,7 @@ static const uint8_t b64ToBits[256] = size_t mpw_base64_decode_max(const char *b64Text) { register const char *b64Cursor = b64Text; - for (; b64ToBits[*b64Cursor] <= 63; ++b64Cursor); + for (; b64ToBits[(uint8_t)*b64Cursor] <= 63; ++b64Cursor); size_t b64Size = b64Cursor - b64Text; // Every 4 b64 chars yield 3 plain bytes => len = 3 * ceil(b64Size / 4) @@ -91,7 +91,7 @@ size_t mpw_base64_decode_max(const char *b64Text) { size_t mpw_base64_decode(uint8_t *plainBuf, const char *b64Text) { register const uint8_t *b64Cursor = (uint8_t *)b64Text; - for (; b64ToBits[*b64Cursor] <= 63; ++b64Cursor); + for (; b64ToBits[(uint8_t)*b64Cursor] <= 63; ++b64Cursor); size_t b64Remaining = b64Cursor - (uint8_t *)b64Text; b64Cursor = (uint8_t *)b64Text;