From f80c999db320aa60570b4e04846bd7beeed96cd6 Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Mon, 31 Oct 2022 16:34:47 +0530 Subject: [PATCH] util/base64: fix heap buffer overflow While updating the destination pointer, we were also adding the padded bytes which are not a part of the decoded bytes. This led to running out of space on the destination buffer. Fix it by only incrementing destination buffer ptr by the number of actual bytes that were decoded. Ticket 5623 --- src/util-base64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util-base64.c b/src/util-base64.c index 7ca32cf435..d3daa24e2d 100644 --- a/src/util-base64.c +++ b/src/util-base64.c @@ -144,7 +144,7 @@ Base64Ecode DecodeBase64(uint8_t *dest, uint32_t dest_size, const uint8_t *src, /* Decode base-64 block into ascii block and move pointer */ DecodeBase64Block(dptr, b64); - dptr += ASCII_BLOCK; + dptr += numDecoded_blk; *decoded_bytes += numDecoded_blk; /* Reset base-64 block and index */ bbidx = 0; -- 2.47.2