From ce26159a03b6ace0f4f7fe837d4b62b102d2b5ee Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 26 Feb 2025 11:37:54 +0100 Subject: [PATCH] detect: constify rule file and lines in parsing and analyzer --- src/detect-engine-analyzer.c | 5 +++-- src/detect-engine-analyzer.h | 4 ++-- src/detect-engine-loader.c | 4 ++-- src/detect.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/detect-engine-analyzer.c b/src/detect-engine-analyzer.c index 7486b9dd80..b17e8929ec 100644 --- a/src/detect-engine-analyzer.c +++ b/src/detect-engine-analyzer.c @@ -166,7 +166,7 @@ static void FpPatternStatsAdd(FpPatternStats *fp, int list, uint16_t patlen) f->tot += patlen; } -void EngineAnalysisFP(const DetectEngineCtx *de_ctx, const Signature *s, char *line) +void EngineAnalysisFP(const DetectEngineCtx *de_ctx, const Signature *s, const char *line) { int fast_pattern_set = 0; int fast_pattern_only_set = 0; @@ -620,7 +620,8 @@ static void EngineAnalysisRulesPrintFP(const DetectEngineCtx *de_ctx, const Sign fprintf(ea_ctx->rule_engine_analysis_fp, "buffer.\n"); } -void EngineAnalysisRulesFailure(const DetectEngineCtx *de_ctx, char *line, char *file, int lineno) +void EngineAnalysisRulesFailure( + const DetectEngineCtx *de_ctx, const char *line, const char *file, int lineno) { fprintf(de_ctx->ea->fp_engine_analysis_fp, "== Sid: UNKNOWN ==\n"); fprintf(de_ctx->ea->fp_engine_analysis_fp, "%s\n", line); diff --git a/src/detect-engine-analyzer.h b/src/detect-engine-analyzer.h index dda71f3384..7419d31856 100644 --- a/src/detect-engine-analyzer.h +++ b/src/detect-engine-analyzer.h @@ -31,11 +31,11 @@ struct DetectEngineCtx_; void SetupEngineAnalysis(struct DetectEngineCtx_ *de_ctx, bool *, bool *); void CleanupEngineAnalysis(struct DetectEngineCtx_ *de_ctx); -void EngineAnalysisFP(const struct DetectEngineCtx_ *de_ctx, const Signature *s, char *line); +void EngineAnalysisFP(const struct DetectEngineCtx_ *de_ctx, const Signature *s, const char *line); void EngineAnalysisRules( const struct DetectEngineCtx_ *de_ctx, const Signature *s, const char *line); void EngineAnalysisRulesFailure( - const struct DetectEngineCtx_ *de_ctx, char *line, char *file, int lineno); + const struct DetectEngineCtx_ *de_ctx, const char *line, const char *file, int lineno); void EngineAnalysisRules2(const struct DetectEngineCtx_ *de_ctx, const Signature *s); diff --git a/src/detect-engine-loader.c b/src/detect-engine-loader.c index 30e931165c..05cd6d016d 100644 --- a/src/detect-engine-loader.c +++ b/src/detect-engine-loader.c @@ -110,8 +110,8 @@ char *DetectLoadCompleteSigPath(const DetectEngineCtx *de_ctx, const char *sig_f * \param badsigs_tot Will store number of invalid signatures in the file * \retval 0 on success, -1 on error */ -static int DetectLoadSigFile( - DetectEngineCtx *de_ctx, char *sig_file, int *goodsigs, int *badsigs, int *skippedsigs) +static int DetectLoadSigFile(DetectEngineCtx *de_ctx, const char *sig_file, int *goodsigs, + int *badsigs, int *skippedsigs) { Signature *sig = NULL; int good = 0, bad = 0, skipped = 0; diff --git a/src/detect.h b/src/detect.h index e48e9e88bb..cea44e7a1b 100644 --- a/src/detect.h +++ b/src/detect.h @@ -947,7 +947,7 @@ typedef struct DetectEngineCtx_ { /** Store rule file and line so that parsers can use them in errors. */ int rule_line; - char *rule_file; + const char *rule_file; const char *sigerror; bool sigerror_silent; bool sigerror_ok;