From: Jason Ish Date: Wed, 16 Nov 2022 16:48:55 +0000 (-0600) Subject: classification: continue processing on parse error X-Git-Tag: suricata-7.0.0-rc1~359 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcd9dabc70eb38d8c2bb797ba860b14e52d894c5;p=thirdparty%2Fsuricata.git classification: continue processing on parse error 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 --- diff --git a/src/util-classification-config.c b/src/util-classification-config.c index 87f52896e7..cafa1c7165 100644 --- a/src/util-classification-config.c +++ b/src/util-classification-config.c @@ -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; } /**