From 816bbeb7dc3684d47d47c35a2255db0671760baa Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 28 Jun 2022 20:20:37 +0200 Subject: [PATCH] fuzz/mime: fix call conditions and args 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. --- src/tests/fuzz/fuzz_mimedecparseline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/fuzz/fuzz_mimedecparseline.c b/src/tests/fuzz/fuzz_mimedecparseline.c index 2230d5891d..e07f5ea31d 100644 --- a/src/tests/fuzz/fuzz_mimedecparseline.c +++ b/src/tests/fuzz/fuzz_mimedecparseline.c @@ -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);