]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: parsing avoiding infinite loop
authorPhilippe Antoine <contact@catenacyber.fr>
Sat, 16 Apr 2022 14:51:42 +0000 (16:51 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 1 Jun 2022 08:54:17 +0000 (10:54 +0200)
by comparing size_t to strlen result
Instead of uint16_t which would loop

Ticket: #5310

src/detect-content.c
src/detect-detection-filter.c
src/detect-engine-prefilter.c
src/detect-msg.c
src/detect-threshold.c

index b5691d416b82d34dd5a853659b0ed1cfe96f29c0..58493266a839c19b58445ab35e14833e5acf778f 100644 (file)
@@ -99,7 +99,7 @@ int DetectContentDataParse(const char *keyword, const char *contentstr,
     char converted = 0;
 
     {
-        uint16_t i, x;
+        size_t i, x;
         uint8_t bin = 0;
         uint8_t escape = 0;
         uint8_t binstr[3] = "";
index 55cfcc21e313ff9b8e73a53720e79078e5a686db..557f72b89ba56a1e604c13c07db637c8cd9b7b2a 100644 (file)
@@ -103,7 +103,7 @@ static DetectThresholdData *DetectDetectionFilterParse (const char *rawstr)
     char *copy_str = NULL, *df_opt = NULL;
     int seconds_found = 0, count_found = 0, track_found = 0;
     int seconds_pos = 0, count_pos = 0;
-    uint16_t pos = 0;
+    size_t pos = 0;
     int i = 0;
     char *saveptr = NULL;
 
index 6cf0fbed5dbe3dfcbdfc4b550e3d75182de68e8a..3173287731fb32c21575d8c515af3898638c797d 100644 (file)
@@ -599,9 +599,8 @@ static uint32_t PrefilterStoreHashFunc(HashListTable *ht, void *data, uint16_t d
     PrefilterStore *ctx = data;
 
     uint32_t hash = strlen(ctx->name);
-    uint16_t u;
 
-    for (u = 0; u < strlen(ctx->name); u++) {
+    for (size_t u = 0; u < strlen(ctx->name); u++) {
         hash += ctx->name[u];
     }
 
index 98bd630d7031b8a461f8d27a535c8ace9e289928..bdc21ef295f4f63f40344bd0b272203ffb9d0d95 100644 (file)
@@ -65,7 +65,7 @@ static int DetectMsgSetup (DetectEngineCtx *de_ctx, Signature *s, const char *ms
     char converted = 0;
 
     {
-        uint16_t i, x;
+        size_t i, x;
         uint8_t escape = 0;
 
         /* it doesn't matter if we need to escape or not we remove the extra "\" to mimic snort */
@@ -194,4 +194,4 @@ void DetectMsgRegisterTests(void)
     UtRegisterTest("DetectMsgParseTest02", DetectMsgParseTest02);
     UtRegisterTest("DetectMsgParseTest03", DetectMsgParseTest03);
 }
-#endif /* UNITTESTS */
\ No newline at end of file
+#endif /* UNITTESTS */
index 4eb72442565851f3ec13ce573b6ce5c199f035e2..e3991b41a2b9cd6463c5995785f4aab3acec3d15 100644 (file)
@@ -118,7 +118,7 @@ static DetectThresholdData *DetectThresholdParse(const char *rawstr)
     int second_found = 0, count_found = 0;
     int type_found = 0, track_found = 0;
     int second_pos = 0, count_pos = 0;
-    uint16_t pos = 0;
+    size_t pos = 0;
     int i = 0;
 
     copy_str = SCStrdup(rawstr);