]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
streaming: fix intersect detection
authorVictor Julien <vjulien@oisf.net>
Sat, 20 May 2023 05:05:16 +0000 (07:05 +0200)
committerVictor Julien <vjulien@oisf.net>
Sun, 21 May 2023 04:46:03 +0000 (06:46 +0200)
Update logic to always use data right edge.

Bug: #5834.

src/util-streaming-buffer.c

index 6d45e38603b868c931d58dbc2f4ffd83816de1bc..a820bc6e00f82fb1ca6f674cebd5e6aed9a71b39 100644 (file)
@@ -991,10 +991,8 @@ static void ListRegions(StreamingBuffer *sb)
  *  Takes the max gap into account.
  */
 static inline bool RegionsIntersect(const StreamingBuffer *sb, const StreamingBufferConfig *cfg,
-        const StreamingBufferRegion *r, const uint64_t offset, const uint32_t len)
+        const StreamingBufferRegion *r, const uint64_t offset, const uint64_t re)
 {
-    const uint64_t re = offset + len;
-
     /* create the data range for the region, adding the max gap */
     const uint64_t reg_o =
             r->stream_offset > cfg->region_gap ? (r->stream_offset - cfg->region_gap) : 0;
@@ -1287,11 +1285,11 @@ static StreamingBufferRegion *BufferInsertAtRegion(StreamingBuffer *sb,
             data_offset + data_len);
     ListRegions(sb);
 
-    if (RegionsIntersect(sb, cfg, &sb->region, data_offset, data_len)) {
+    if (RegionsIntersect(sb, cfg, &sb->region, data_offset, data_offset + data_len)) {
         SCLogDebug("data_offset %" PRIu64 ", data_len %u intersects with main region (next %p)",
                 data_offset, data_len, sb->region.next);
         if (sb->region.next == NULL ||
-                !RegionsIntersect(sb, cfg, sb->region.next, data_offset, data_len)) {
+                !RegionsIntersect(sb, cfg, sb->region.next, data_offset, data_offset + data_len)) {
             SCLogDebug(
                     "data_offset %" PRIu64
                     ", data_len %u intersects with main region, no next or way before next region",