]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: validate code
authorVictor Julien <victor@inliniac.net>
Tue, 28 Feb 2017 22:13:00 +0000 (23:13 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 20 Apr 2017 15:41:11 +0000 (17:41 +0200)
src/stream-tcp-list.c

index fbd697d8719e6d14a8f7bd1dbc584731a1da51ef..2546c5d3d2036518bc9d851078bd0d8d37a30184 100644 (file)
@@ -913,6 +913,24 @@ void PrintList(TcpSegment *seg)
     }
 }
 
+void ValidateList(const TcpStream *stream)
+{
+    TcpSegment *seg = stream->seg_list;
+    TcpSegment *prev_seg = NULL;
+
+    BUG_ON(seg && seg->next == NULL && stream->seg_list != stream->seg_list_tail);
+    BUG_ON(stream->seg_list != stream->seg_list_tail && stream->seg_list_tail->prev == NULL);
+
+    while (seg != NULL) {
+        prev_seg = seg;
+        seg = seg->next;
+        BUG_ON(seg && seg->prev != prev_seg);
+
+        // equal is possible
+        BUG_ON(seg && SEQ_LT(seg->seq, prev_seg->seq));
+    }
+}
+
 /*
  *  unittests
  */