From dcd9dabc70eb38d8c2bb797ba860b14e52d894c5 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 16 Nov 2022 10:48:55 -0600 Subject: [PATCH] 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 --- src/util-classification-config.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; } /** -- 2.47.2