]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
fuzz: limit input size for protocol detection consistency check
authorPhilippe Antoine <contact@catenacyber.fr>
Mon, 6 Apr 2020 15:28:33 +0000 (17:28 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 6 Apr 2020 17:10:44 +0000 (19:10 +0200)
src/tests/fuzz/fuzz_applayerprotodetectgetproto.c

index 8fb0609e85e8fd04b5ff31ab779f2f77a32379b3..27b271924e5cd88e621279b7255ea08a29e0ae30 100644 (file)
@@ -14,6 +14,8 @@
 
 #define HEADER_LEN 6
 
+//rule of thumb constant, so as not to timeout target
+#define PROTO_DETECT_MAX_LEN 1024
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
@@ -59,7 +61,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
          * we find the same protocol or ALPROTO_UNKNOWN.
          * Otherwise, we have evasion with TCP splitting
          */
-        for (size_t i = 0; i < size-HEADER_LEN; i++) {
+        for (size_t i = 0; i < size-HEADER_LEN && i < PROTO_DETECT_MAX_LEN; i++) {
             alproto2 = AppLayerProtoDetectGetProto(alpd_tctx, f, data+HEADER_LEN, i, f->proto, data[0], &reverse);
             if (alproto2 != ALPROTO_UNKNOWN && alproto2 != alproto) {
                 printf("Assertion failure : With input length %"PRIuMAX", found %s instead of %s\n", (uintmax_t) i, AppProtoToString(alproto2), AppProtoToString(alproto));