]> 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>
Mon, 13 Jun 2022 18:13:57 +0000 (20:13 +0200)
by comparing size_t to strlen result
Instead of uint16_t which would loop

Ticket: #5310
(cherry picked from commit ced96a8aadd8a9a4ce3d8d689ac53f7eedbbe8e9)

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

index b3210c55f5e0041cd0bdf58a2d7655707f212124..6d0041bbe7f86f7743c135398324ae42c3ade8d9 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 b4f57d1c4ad90f07f32144510605c1723b692aa9..c953251439387ec879694164b8f068ef86fa2474 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 11cb3c878fe8e454298908148eedac558e8a0548..67ac7725f37859f4b159179a53c24e5a494d404f 100644 (file)
@@ -522,9 +522,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 cf8cb7f3789898e2baca31954300a254fa8c21b3..c6a9da0679c7611eb6d9aa8937736e16844f07c9 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 */
@@ -219,4 +219,4 @@ void DetectMsgRegisterTests(void)
     UtRegisterTest("DetectMsgParseTest02", DetectMsgParseTest02);
     UtRegisterTest("DetectMsgParseTest03", DetectMsgParseTest03);
 }
-#endif /* UNITTESTS */
\ No newline at end of file
+#endif /* UNITTESTS */
index baf8aea550b1b2d25daffe169d2c00e79a1971af..1fd21da8932e9494e193d43f7e7a0ce8125e212c 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);