From: Victor Julien Date: Tue, 21 Mar 2023 05:37:19 +0000 (+0100) Subject: detect/content: cleanup content setup/check code X-Git-Tag: suricata-7.0.0-rc2~437 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92d8a712aa4569d92630d19e1b3e9902aa0804f8;p=thirdparty%2Fsuricata.git detect/content: cleanup content setup/check code Pass SigMatch pointer instead of a list id to SigParseRequiredContentSize. --- diff --git a/src/detect-bsize.c b/src/detect-bsize.c index 6639742f8e..4c89abc3c6 100644 --- a/src/detect-bsize.c +++ b/src/detect-bsize.c @@ -64,7 +64,7 @@ bool DetectBsizeValidateContentCallback(Signature *s, int list) uint64_t needed; if (bsize >= 0) { int len, offset; - SigParseRequiredContentSize(s, bsize, list, &len, &offset); + SigParseRequiredContentSize(s, bsize, s->init_data->smlists[list], &len, &offset); SCLogDebug("bsize: %d; len: %d; offset: %d [%s]", bsize, len, offset, s->sig_str); needed = len; if (len > bsize) { diff --git a/src/detect-content.c b/src/detect-content.c index 891eee523a..a66497d400 100644 --- a/src/detect-content.c +++ b/src/detect-content.c @@ -412,13 +412,8 @@ void DetectContentFree(DetectEngineCtx *de_ctx, void *ptr) * - Negated content values are checked but not accumulated for the required size. */ void SigParseRequiredContentSize( - const Signature *s, const int max_size, int list, int *len, int *offset) + const Signature *s, const int max_size, const SigMatch *sm, int *len, int *offset) { - if (list > (int)s->init_data->smlists_array_size) { - return; - } - - SigMatch *sm = s->init_data->smlists[list]; int max_offset = 0, total_len = 0; bool first = true; for (; sm != NULL; sm = sm->next) { diff --git a/src/detect-content.h b/src/detect-content.h index ae179ad076..d1f3d6fbc1 100644 --- a/src/detect-content.h +++ b/src/detect-content.h @@ -132,6 +132,6 @@ void DetectContentPropagateLimits(Signature *s); void DetectContentPatternPrettyPrint(const DetectContentData *cd, char *str, size_t str_len); void SigParseRequiredContentSize( - const Signature *s, const int max, int list, int *len, int *offset); + const Signature *s, const int max, const SigMatch *sm, int *len, int *offset); #endif /* __DETECT_CONTENT_H__ */ diff --git a/src/detect-dsize.c b/src/detect-dsize.c index 9d62457fc1..4336e3546b 100644 --- a/src/detect-dsize.c +++ b/src/detect-dsize.c @@ -315,7 +315,8 @@ int SigParseMaxRequiredDsize(const Signature *s) } int total_length, offset; - SigParseRequiredContentSize(s, dsize, DETECT_SM_LIST_PMATCH, &total_length, &offset); + SigParseRequiredContentSize( + s, dsize, s->init_data->smlists[DETECT_SM_LIST_PMATCH], &total_length, &offset); SCLogDebug("dsize: %d len: %d; offset: %d [%s]", dsize, total_length, offset, s->sig_str); if (total_length > dsize) {