]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
classification: continue processing on parse error
authorJason Ish <jason.ish@oisf.net>
Wed, 16 Nov 2022 16:48:55 +0000 (10:48 -0600)
committerVictor Julien <vjulien@oisf.net>
Fri, 18 Nov 2022 07:27:02 +0000 (08:27 +0100)
Instead of returning on the first line that fails to parse, log the
error and continue instead of returning.

The fail fast makes sense in test mode, but not in a normal run mode
where you don't want one bad line to abort processing the whole file.

This will still fail out in test mode.

Related issue: 4554

src/util-classification-config.c

index 87f52896e79285f87977de7061250a87908a98ea..cafa1c7165c204a32f2aefa1c2f1a78930076c66 100644 (file)
@@ -350,15 +350,17 @@ static bool SCClassConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
 {
     char line[1024];
     uint16_t i = 1;
+    int errors = 0;
 
     while (fgets(line, sizeof(line), fd) != NULL) {
         if (SCClassConfIsLineBlankOrComment(line))
             continue;
 
         if (SCClassConfAddClasstype(de_ctx, line, i) == -1) {
-            return false;
+            errors++;
+        } else {
+            i++;
         }
-        i++;
     }
 
 #ifdef UNITTESTS
@@ -366,7 +368,7 @@ static bool SCClassConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
               de_ctx->class_conf_ht->count);
 #endif
 
-    return true;
+    return errors == 0;
 }
 
 /**