]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fuzz: fixes a leak in applayerparse target
authorPhilippe Antoine <contact@catenacyber.fr>
Mon, 20 Sep 2021 18:45:10 +0000 (20:45 +0200)
committerVictor Julien <vjulien@oisf.net>
Fri, 25 Nov 2022 19:12:31 +0000 (20:12 +0100)
If a protocol change was requested, the target did not handle
it as Suricata, as the target is meant to handle only one
app-layer protocol.

(cherry picked from commit ca054f726464fcc55242b7c851d75557c96b3d83)

src/tests/fuzz/fuzz_applayerparserparse.c

index 06a8ad4e8befafd9fc10650102021a7193866d26..6d5a560cd7787e2f5b48e8bfad8dfdd0a20126e6 100644 (file)
@@ -133,6 +133,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
             memcpy(isolatedBuffer, albuffer, alnext - albuffer);
             (void) AppLayerParserParse(NULL, alp_tctx, f, f->alproto, flags, isolatedBuffer, alnext - albuffer);
             free(isolatedBuffer);
+            if (FlowChangeProto(f)) {
+                // exits if a protocol change is requested
+                alsize = 0;
+                break;
+            }
             flags &= ~(STREAM_START);
             if (f->alparser &&
                    (((flags & STREAM_TOSERVER) != 0 &&