From 8faacb727dcbaf22f6b954f2fc33c444e1d92298 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 23 Mar 2011 14:41:01 +0100 Subject: [PATCH] Account for seg list not always being empty when stream closes. --- src/stream-tcp-reassemble.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 0fd913634d..65771aaf27 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -2617,7 +2617,13 @@ static int StreamTcpReassembleAppLayer (TcpReassemblyThreadCtx *ra_ctx, PrintList(stream->seg_list); #endif - if (stream->seg_list == NULL) { + /* if no segments are in the list or all are already processed, + * and state is beyond established, we send an empty msg */ + TcpSegment *seg_tail = stream->seg_list_tail; + if (seg_tail == NULL || + (seg_tail->flags & SEGMENTTCP_FLAG_RAW_PROCESSED && + seg_tail->flags & SEGMENTTCP_FLAG_APPLAYER_PROCESSED)) + { /* send an empty EOF msg if we have no segments but TCP state * is beyond ESTABLISHED */ if (ssn->state > TCP_ESTABLISHED) { @@ -2631,13 +2637,17 @@ static int StreamTcpReassembleAppLayer (TcpReassemblyThreadCtx *ra_ctx, * release reassembly for both directions. */ ssn->flags |= STREAMTCP_FLAG_TOSERVER_REASSEMBLY_STARTED; - } else { - SCLogDebug("no segments in the list to reassemble"); + SCReturnInt(0); } + } + /* no segments, nothing to do */ + if (stream->seg_list == NULL) { + SCLogDebug("no segments in the list to reassemble"); SCReturnInt(0); } + /* check if reassembling has been paused for the moment or not */ if (stream->flags & STREAMTCP_STREAM_FLAG_PAUSE_REASSEMBLY) { SCLogDebug("reassembling has been paused for this stream, so no"