From: Victor Julien Date: Wed, 26 Aug 2015 14:52:09 +0000 (+0200) Subject: debug validation: add segment list sanity check X-Git-Tag: suricata-3.0RC1~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa8dc77dcc73e3e4b9c0374b6eec8b3e5f379fd8;p=thirdparty%2Fsuricata.git debug validation: add segment list sanity check --- diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 632b966fc0..dbf9c71eb7 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -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) {