]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fuzz/mime: fix call conditions and args 7587/head
authorVictor Julien <vjulien@oisf.net>
Tue, 28 Jun 2022 18:20:37 +0000 (20:20 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 29 Jun 2022 18:01:53 +0000 (20:01 +0200)
The SMTP parser should not supply lines w/o EOL chars to the mime
parser unless its in the BODY parsing stage. Mimic this in the fuzz
target by testing the state for inputs that have no EOL.

Additionally, make sure the delim cnt reflects the missing EOL.

(cherry picked from commit 816bbeb7dc3684d47d47c35a2255db0671760baa)

src/tests/fuzz/fuzz_mimedecparseline.c

index 2230d5891d0e03282e19cfaa24048f19f36d38af..e07f5ea31dbba4460b16af7d858b817f54028b8f 100644 (file)
@@ -43,7 +43,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
     while (1) {
         uint8_t * next = memchr(buffer, '\n', size);
         if (next == NULL) {
-            (void) MimeDecParseLine(buffer, size, 1, state);
+            if (state->state_flag >= BODY_STARTED)
+                (void)MimeDecParseLine(buffer, size, 0, state);
             break;
         } else {
             (void) MimeDecParseLine(buffer, next - buffer, 1, state);