From: Justin Viiret Date: Tue, 15 Mar 2016 01:38:23 +0000 (+1100) Subject: mpm: pass offset, depth args to add functions X-Git-Tag: suricata-3.0.1~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c37195c95fa57d8a9ce1b3bcf9c5e185b37fd5a3;p=thirdparty%2Fsuricata.git 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. --- diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index 9d1a9fc162..d5447aea74 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -1216,28 +1216,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); } }