]> 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>
Tue, 29 Nov 2022 09:33:15 +0000 (10:33 +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

src/util-base64.c

index 7ca32cf43567ce9da8fc3ced6ab111d1dc78969e..d3daa24e2deb3635bfc421e7dcb3fa574631d72f 100644 (file)
@@ -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;