Skip to content

Commit

Permalink
base64: further simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
catenacyber committed Jul 12, 2023
1 parent 7f98ce1 commit a024068
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/util-base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,8 @@ Base64Ecode DecodeBase64(uint8_t *dest, uint32_t dest_size, const uint8_t *src,
}
}

if (bbidx > 0 && !valid && mode == BASE64_MODE_RFC4648) {
/* Decoded bytes for 1 or 2 base64 encoded bytes is 1 */
padding += bbidx > 1 ? B64_BLOCK - bbidx : 2;
uint32_t numDecoded_blk = ASCII_BLOCK - (padding < B64_BLOCK ? padding : ASCII_BLOCK);
if (dest_size < *decoded_bytes + numDecoded_blk) {
SCLogDebug("Destination buffer full");
ecode = BASE64_ECODE_BUF;
numDecoded_blk = dest_size - *decoded_bytes;
}
*decoded_bytes += numDecoded_blk;
DecodeBase64Block(dptr, b64, numDecoded_blk);
*consumed_bytes += bbidx;
} else if (bbidx > 0 && valid && mode != BASE64_MODE_RFC2045) {
/* Finish remaining b64 bytes by padding */
/* Decode remaining */
if (bbidx > 0 && mode != BASE64_MODE_RFC2045 && (valid || mode == BASE64_MODE_RFC4648)) {
/* Finish remaining b64 bytes by padding and decode remaining */
padding += B64_BLOCK - bbidx;
uint32_t numDecoded_blk = ASCII_BLOCK - (padding < B64_BLOCK ? padding : ASCII_BLOCK);
if (dest_size < *decoded_bytes + numDecoded_blk) {
Expand Down

0 comments on commit a024068

Please sign in to comment.