]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
debug validation: add segment list sanity check
authorVictor Julien <victor@inliniac.net>
Wed, 26 Aug 2015 14:52:09 +0000 (16:52 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 18 Sep 2015 14:55:18 +0000 (16:55 +0200)
src/stream-tcp-reassemble.c

index 632b966fc0f91e146387ceee2ae3dd4a6e976457..dbf9c71eb74e81a2059be4eed45b4a71bf50f697 100644 (file)
@@ -2967,9 +2967,14 @@ int StreamTcpReassembleAppLayer (ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
             SCReturnInt(0);
         }
     }
-
+#ifdef DEBUG_VALIDATION
+    uint64_t bytes = 0;
+#endif
     for (; seg != NULL; )
     {
+#ifdef DEBUG_VALIDATION
+        bytes += seg->payload_len;
+#endif
         /* if in inline mode, we process all segments regardless of whether
          * they are ack'd or not. In non-inline, we process only those that
          * are at least partly ack'd. */
@@ -3014,6 +3019,9 @@ int StreamTcpReassembleAppLayer (ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
         }
         seg = next_seg;
     }
+#ifdef DEBUG_VALIDATION /* we should never have this much data queued */
+    BUG_ON(bytes > 1000000ULL && bytes > (stream->window * 1.5));
+#endif
 
     /* put the partly filled smsg in the queue to the l7 handler */
     if (rd.data_len > 0) {