Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect/content: account for distance variables #12297

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/detect-engine-content-inspection.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,17 @@ static int DetectEngineContentInspectionInternal(DetectEngineThreadCtx *det_ctx,
}

if (stream_start_offset != 0 && prev_buffer_offset == 0) {
SCLogDebug("stream_start_offset: %" PRIi32 ", depth %" PRIu32,
stream_start_offset, depth);
if (depth <= stream_start_offset) {
goto no_match;
} else if (depth >= (stream_start_offset + buffer_len)) {
;
} else {
depth = depth - stream_start_offset;
}
SCLogDebug("depth is now %" PRIu32 ", stream_start_offset: %" PRIi32, depth,
stream_start_offset);
}
}

Expand All @@ -202,7 +206,10 @@ static int DetectEngineContentInspectionInternal(DetectEngineThreadCtx *det_ctx,
depth = prev_buffer_offset + cd->depth;
}

SCLogDebug("cd->depth %"PRIu32", depth %"PRIu32, cd->depth, depth);
SCLogDebug("cd->depth %" PRIu32 ", depth %" PRIu32
" , prev_offset %" PRIi32,
cd->depth, depth, prev_buffer_offset);
depth += offset;
}
}

Expand Down Expand Up @@ -246,8 +253,8 @@ static int DetectEngineContentInspectionInternal(DetectEngineThreadCtx *det_ctx,
/* If the value came from a variable, make sure to adjust the depth so it's relative
* to the offset value.
*/
if (cd->flags & (DETECT_CONTENT_DISTANCE_VAR|DETECT_CONTENT_OFFSET_VAR|DETECT_CONTENT_DEPTH_VAR)) {
depth += offset;
if (cd->flags & (DETECT_CONTENT_OFFSET_VAR | DETECT_CONTENT_DEPTH_VAR)) {
depth += offset;
}

/* update offset with prev_offset if we're searching for
Expand Down
Loading