detect/content: cleanup content setup/check code

Pass SigMatch pointer instead of a list id to SigParseRequiredContentSize.
pull/8727/head
Victor Julien 3 years ago
parent fd46c93a8f
commit 92d8a712aa

@ -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) {

@ -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) {

@ -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__ */

@ -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) {

Loading…
Cancel
Save