From: Victor Julien Date: Tue, 28 Feb 2017 22:13:00 +0000 (+0100) Subject: stream: validate code X-Git-Tag: suricata-4.0.0-beta1~154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee00a6f2ec9d91d343a15f7de487dd58a03edbd4;p=thirdparty%2Fsuricata.git stream: validate code --- diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index fbd697d871..2546c5d3d2 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -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 */