]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util/base64: fix heap buffer overflow
authorShivani Bhardwaj <shivani@oisf.net>
Mon, 31 Oct 2022 11:04:47 +0000 (16:34 +0530)
committerVictor Julien <vjulien@oisf.net>
Sun, 27 Nov 2022 06:19:07 +0000 (07:19 +0100)
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
Ticket 5694

src/util-base64.c

index 531dac30445720af42d220cac28f5634103ededb..8cc81130399b4ecfb6a1e703081d638d1694ee3a 100644 (file)
@@ -143,7 +143,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;