mpm: pass offset, depth args to add functions

MpmAddPatternCI and MpmAddPatternCS had arguments for offset and depth,
but these were not being passed in by the caller.
pull/1966/head
Justin Viiret 10 years ago committed by Victor Julien
parent c8e01a3d62
commit c37195c95f

@ -1216,28 +1216,40 @@ static void PopulateMpmHelperAddPatternToPktCtx(MpmCtx *mpm_ctx,
Signature *s, uint8_t flags, Signature *s, uint8_t flags,
int chop) 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 (cd->flags & DETECT_CONTENT_NOCASE) {
if (chop) { if (chop) {
MpmAddPatternCI(mpm_ctx, MpmAddPatternCI(mpm_ctx,
cd->content + cd->fp_chop_offset, cd->fp_chop_len, cd->content + cd->fp_chop_offset, cd->fp_chop_len,
0, 0, pat_offset, pat_depth,
cd->id, s->num, flags); cd->id, s->num, flags);
} else { } else {
MpmAddPatternCI(mpm_ctx, MpmAddPatternCI(mpm_ctx,
cd->content, cd->content_len, cd->content, cd->content_len,
0, 0, pat_offset, pat_depth,
cd->id, s->num, flags); cd->id, s->num, flags);
} }
} else { } else {
if (chop) { if (chop) {
MpmAddPatternCS(mpm_ctx, MpmAddPatternCS(mpm_ctx,
cd->content + cd->fp_chop_offset, cd->fp_chop_len, cd->content + cd->fp_chop_offset, cd->fp_chop_len,
0, 0, pat_offset, pat_depth,
cd->id, s->num, flags); cd->id, s->num, flags);
} else { } else {
MpmAddPatternCS(mpm_ctx, MpmAddPatternCS(mpm_ctx,
cd->content, cd->content_len, cd->content, cd->content_len,
0, 0, pat_offset, pat_depth,
cd->id, s->num, flags); cd->id, s->num, flags);
} }
} }

Loading…
Cancel
Save