108 uint32_t buffer_len, uint32_t stream_start_offset, uint8_t
flags, uint8_t inspection_mode)
122 if (smd == NULL || buffer == NULL) {
131 SCLogDebug(
"inspecting content %"PRIu32
" buffer_len %"PRIu32, cd->
id, buffer_len);
147 const uint8_t *found = NULL;
149 uint32_t depth = buffer_len;
150 uint32_t prev_offset = 0;
158 offset = prev_buffer_offset;
166 if (distance < 0 && (uint32_t)(abs(distance)) >
offset)
171 SCLogDebug(
"cd->distance %"PRIi32
", offset %"PRIu32
", depth %"PRIu32,
177 if ((int32_t)depth > (int32_t)(prev_buffer_offset + det_ctx->
byte_values[cd->
within] + distance)) {
181 if ((int32_t)depth > (int32_t)(prev_buffer_offset + cd->
within + distance)) {
182 depth = prev_buffer_offset + cd->
within + distance;
185 SCLogDebug(
"cd->within %"PRIi32
", det_ctx->buffer_offset %"PRIu32
", depth %"PRIu32,
186 cd->
within, prev_buffer_offset, depth);
189 if (stream_start_offset != 0 && prev_buffer_offset == 0) {
190 if (depth <= stream_start_offset) {
192 }
else if (depth >= (stream_start_offset + buffer_len)) {
195 depth = depth - stream_start_offset;
205 if (cd->
depth != 0) {
206 if ((cd->
depth + prev_buffer_offset) < depth) {
207 depth = prev_buffer_offset + cd->
depth;
228 if (cd->
depth != 0) {
234 if (depth <= stream_start_offset) {
236 }
else if (depth >= (stream_start_offset + buffer_len)) {
239 depth = depth - stream_start_offset;
248 prev_buffer_offset = 0;
261 if (prev_offset != 0)
266 if (depth > buffer_len)
271 if (
offset > depth || depth == 0) {
279 const uint8_t *sbuffer = buffer +
offset;
280 uint32_t sbuffer_len = depth -
offset;
281 uint32_t match_offset = 0;
282 SCLogDebug(
"sbuffer_len %" PRIu32
" depth: %" PRIu32
", buffer_len: %" PRIu32,
283 sbuffer_len, depth, buffer_len);
285 BUG_ON(sbuffer_len > buffer_len);
288 SCLogDebug(
"depth < buffer_len while DETECT_CONTENT_ENDS_WITH is set. Can't possibly match.");
314 match_offset = (uint32_t)((found - buffer) + cd->
content_len);
316 SCLogDebug(
"content %" PRIu32
" matched at offset %" PRIu32
317 ", but negated so no match",
318 cd->
id, match_offset);
324 if (sbuffer_len != match_offset) {
325 SCLogDebug(
"content \"%s\" %" PRIu32
" matched at offset %" PRIu32
326 ", but not at end of buffer so match",
335 SCLogDebug(
"content %" PRIu32
" matched at offset %" PRIu32
"", cd->
id,
346 det_ctx->
replist, (uint8_t *)found, cd);
364 buffer, buffer_len, stream_start_offset,
flags, inspection_mode);
371 SCLogDebug(
"'next sm' said to discontinue this right now");
377 SCLogDebug(
"'next sm' does not depend on me, so we can give up");
382 SCLogDebug(
"'next sm' depends on me %p, lets see what we can do (flags %u)",
386 prev_offset = (match_offset - (cd->
content_len - 1));
387 SCLogDebug(
"trying to see if there is another match after prev_offset %" PRIu32,
398 uint32_t dataat = id->
dataat;
401 if (be_value >= 100000000) {
403 SCLogDebug(
"extracted value %"PRIu64
" very big: no match", be_value);
406 SCLogDebug(
"extracted value way %"PRIu64
" very big: match", be_value);
409 dataat = (uint32_t)be_value;
410 SCLogDebug(
"isdataat: using value %u from byte_extract local_id %u", dataat, id->
dataat);
415 SCLogDebug(
"det_ctx->buffer_offset + dataat %"PRIu32
" > %"PRIu32, det_ctx->
buffer_offset + dataat, buffer_len);
426 if (dataat < buffer_len) {
432 SCLogDebug(
"absolute isdataat mismatch, id->isdataat %"PRIu32
", buffer_len %"PRIu32
"", dataat, buffer_len);
443 uint32_t prev_offset = 0;
455 SCLogDebug(
"no relative match coming up, so this is a match");
467 p, f, buffer, buffer_len, stream_start_offset,
flags,
482 uint16_t btflags = btd->
flags;
484 uint64_t value = btd->
value;
485 int32_t nbytes = btd->
nbytes;
490 value = det_ctx->byte_values[value];
493 nbytes = det_ctx->byte_values[nbytes];
514 uint16_t bjflags = bjd->
flags;
523 nbytes = det_ctx->byte_values[bjd->
nbytes];
538 det_ctx, s, smd->ctx, buffer, buffer_len, bjflags, nbytes,
offset)) {
547 uint8_t endian = bed->
endian;
562 &det_ctx->byte_values[bed->
local_id], endian) != 1) {
566 SCLogDebug(
"[BE] Fetched value for index %d: %"PRIu64,
572 DetectByteMathData *bmd = (DetectByteMathData *)smd->ctx;
573 uint8_t endian = bmd->endian;
577 if ((bmd->flags & DETECT_BYTEMATH_FLAG_ENDIAN) && endian == (int)EndianDCE &&
585 if (bmd->flags & DETECT_BYTEMATH_FLAG_RVALUE_VAR) {
586 rvalue = det_ctx->byte_values[bmd->rvalue];
588 rvalue = bmd->rvalue;
592 if (bmd->flags & DETECT_BYTEMATH_FLAG_NBYTES_VAR) {
593 nbytes = (uint8_t)det_ctx->byte_values[bmd->nbytes];
595 nbytes = bmd->nbytes;
600 &det_ctx->byte_values[bmd->local_id], endian) != 1) {
604 SCLogDebug(
"[BM] Fetched value for index %d: %"PRIu64,
605 bmd->local_id, det_ctx->byte_values[bmd->local_id]);
611 const uint64_t data_size = buffer_len + stream_start_offset;
614 det_ctx->discontinue_matching = 1;
630 det_ctx->discontinue_matching = 1;
641 det_ctx->discontinue_matching = 1;
648 DetectUrilenData *urilend = (DetectUrilenData *) smd->ctx;
649 if (buffer_len > UINT16_MAX) {
659 det_ctx->discontinue_matching = 0;
668 det_ctx->buffer_offset, f) != 1)
703 buffer_len, stream_start_offset,
flags, inspection_mode);