The destination buffer should be able to hold at least 3 Bytes during
the processing of the last block of data. If it cannot hold at least 3
Bytes, then that may lead to dynamic buffer overflow while decoding.
ecode = BASE64_ECODE_BUF;
return ecode;
}
+ /* if the destination size is not at least 3 Bytes long, it'll give a dynamic
+ * buffer overflow while decoding, so, return and let the caller take care of the
+ * remaining bytes to be decoded which should always be < 4 at this stage */
+ if (dest_size - *decoded_bytes < 3)
+ return BASE64_ECODE_BUF;
*decoded_bytes += numDecoded_blk;
DecodeBase64Block(dptr, b64);
*consumed_bytes += bbidx;