]> 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>
Tue, 14 Jun 2022 08:13:45 +0000 (10: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 b88399681cf884f641cb61b1dc5ad7b2a5b5720f..52f6897adf3c4e8563aa09aaf5b95372bcd1958a 100644 (file)
@@ -95,7 +95,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 571d699ee6cc5da52e6fb80874bb9ba04c121b0d..71127c10b307ff821541468e3291c0a3a639d865 100644 (file)
@@ -101,7 +101,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 98477243ec928902309800d47f118f3701678b05..ad231dca8eab65c194440f0765d87dd4da9c824d 100644 (file)
@@ -468,9 +468,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 302f74501db79d370b10dc8dbaac6f2bfd65074d..68ba9ca83b7889386ea119eb7d822e9220d6375e 100644 (file)
@@ -61,7 +61,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,3 @@ void DetectMsgRegisterTests(void)
     UtRegisterTest("DetectMsgParseTest03", DetectMsgParseTest03);
 #endif /* UNITTESTS */
 }
-
index 2567453af997d60962063090727ba110eea3cef5..4c9cb50fccc5abc829b97818628e8feb3a0eaa88 100644 (file)
@@ -115,7 +115,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);