From: Victor Julien Date: Mon, 27 Jun 2022 14:20:02 +0000 (+0200) Subject: mime/base64: fix final data not getting processed X-Git-Tag: suricata-5.0.10~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57adc048efcd3ffc67e9c215fc9ea071250a277e;p=thirdparty%2Fsuricata.git mime/base64: fix final data not getting processed If the last data of the body was not a multple of 4 and not padded to be a multiple of 4, it would not be processed. (cherry picked from commit 0d6ab727c55cbda04404ec44c5aa6582f3922478) --- diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index 12be127e45..0586eda47f 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -1236,6 +1236,14 @@ static uint8_t ProcessBase64Remainder( state->bvr_len = cnt; } + /* in force mode pad the block */ + if (force && cnt != B64_BLOCK) { + SCLogDebug("force and cnt %u != %u", cnt, B64_BLOCK); + for (uint8_t i = state->bvr_len; i < B64_BLOCK; i++) { + state->bvremain[state->bvr_len++] = '='; + } + } + /* If data chunk buffer will be full, then clear it now */ if (DATA_CHUNK_SIZE - state->data_chunk_len < ASCII_BLOCK) {