Skip to content

Commit

Permalink
mpm: pass offset, depth args to add functions
Browse files Browse the repository at this point in the history
MpmAddPatternCI and MpmAddPatternCS had arguments for offset and depth,
but these were not being passed in by the caller.
  • Loading branch information
Justin Viiret committed Mar 15, 2016
1 parent f17ef5e commit 87bd04a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/detect-engine-mpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,28 +1211,40 @@ static void PopulateMpmHelperAddPatternToPktCtx(MpmCtx *mpm_ctx,
Signature *s, uint8_t flags,
int chop)
{
uint16_t pat_offset = cd->offset;
uint16_t pat_depth = cd->depth;

/* recompute offset/depth to cope with chop */
if (chop && (pat_depth || pat_offset)) {
pat_offset += cd->fp_chop_offset;
if (pat_depth) {
pat_depth -= cd->content_len;
pat_depth += cd->fp_chop_offset + cd->fp_chop_len;
}
}

if (cd->flags & DETECT_CONTENT_NOCASE) {
if (chop) {
MpmAddPatternCI(mpm_ctx,
cd->content + cd->fp_chop_offset, cd->fp_chop_len,
0, 0,
pat_offset, pat_depth,
cd->id, s->num, flags);
} else {
MpmAddPatternCI(mpm_ctx,
cd->content, cd->content_len,
0, 0,
pat_offset, pat_depth,
cd->id, s->num, flags);
}
} else {
if (chop) {
MpmAddPatternCS(mpm_ctx,
cd->content + cd->fp_chop_offset, cd->fp_chop_len,
0, 0,
pat_offset, pat_depth,
cd->id, s->num, flags);
} else {
MpmAddPatternCS(mpm_ctx,
cd->content, cd->content_len,
0, 0,
pat_offset, pat_depth,
cd->id, s->num, flags);
}
}
Expand Down

0 comments on commit 87bd04a

Please sign in to comment.