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
pull/8218/head
Shivani Bhardwaj 3 years ago committed by Victor Julien
parent c56fa0a805
commit f80c999db3

@ -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 */ /* Decode base-64 block into ascii block and move pointer */
DecodeBase64Block(dptr, b64); DecodeBase64Block(dptr, b64);
dptr += ASCII_BLOCK; dptr += numDecoded_blk;
*decoded_bytes += numDecoded_blk; *decoded_bytes += numDecoded_blk;
/* Reset base-64 block and index */ /* Reset base-64 block and index */
bbidx = 0; bbidx = 0;

Loading…
Cancel
Save