]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mime/base64: fix final data not getting processed
authorVictor Julien <vjulien@oisf.net>
Mon, 27 Jun 2022 14:20:02 +0000 (16:20 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 29 Jun 2022 17:59:15 +0000 (19:59 +0200)
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)

src/util-decode-mime.c

index 99e215b84bd087155d635e9339dea961ab122d81..3ad55236f9c7a3aa76893c39c1aad88ff3efa7a3 100644 (file)
@@ -1235,6 +1235,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) {