Properly update depth if offset+content_len < depth. Fixes #164.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent e704d90aaa
commit dab679889c

@ -72,6 +72,7 @@ static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depths
DetectUricontentData *ud = NULL; DetectUricontentData *ud = NULL;
DetectContentData *cd = NULL; DetectContentData *cd = NULL;
switch (pm->type) { switch (pm->type) {
case DETECT_URICONTENT: case DETECT_URICONTENT:
ud = (DetectUricontentData *)pm->ctx; ud = (DetectUricontentData *)pm->ctx;
@ -82,9 +83,12 @@ static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depths
} }
ud->depth = (uint32_t)atoi(str); ud->depth = (uint32_t)atoi(str);
if (ud->uricontent_len + ud->offset > ud->depth) { if (ud->uricontent_len + ud->offset > ud->depth) {
uint32_t depth = (ud->depth > ud->uricontent_len) ?
ud->depth : ud->uricontent_len;
cd->depth = cd->offset + depth;
SCLogDebug("depth increased to %"PRIu32" to match pattern len " SCLogDebug("depth increased to %"PRIu32" to match pattern len "
"and offset", ud->uricontent_len + ud->offset); "and offset", ud->depth);
ud->depth = ud->uricontent_len + ud->offset;
} }
break; break;
@ -97,9 +101,12 @@ static int DetectDepthSetup (DetectEngineCtx *de_ctx, Signature *s, char *depths
} }
cd->depth = (uint32_t)atoi(str); cd->depth = (uint32_t)atoi(str);
if (cd->content_len + cd->offset > cd->depth) { if (cd->content_len + cd->offset > cd->depth) {
uint32_t depth = (cd->depth > cd->content_len) ?
cd->depth : cd->content_len;
cd->depth = cd->offset + depth;
SCLogDebug("depth increased to %"PRIu32" to match pattern len " SCLogDebug("depth increased to %"PRIu32" to match pattern len "
"and offset", cd->content_len + cd->offset); "and offset", cd->depth);
cd->depth = cd->content_len + cd->offset;
} }
break; break;

Loading…
Cancel
Save