]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream-tcp-reassemble: fix reassembly direction for FIN packets
authorAngelo Mirabella <amirabella@lastline.com>
Thu, 20 Jan 2022 14:52:33 +0000 (14:52 +0000)
committerVictor Julien <vjulien@oisf.net>
Fri, 28 Jan 2022 06:50:09 +0000 (07:50 +0100)
Suricata invokes the stream reassembly logic only for the current packet
direction if the packet contains a FIN flag. However, this does not
handle the case in which the packet ACKs data from the opposing direction.
This patch forces the invocation of the stream reassembly logic
on both direction when Suricata sees a FIN packet.

(cherry picked from commit 41a139b590a059171d0517a455c562486e1a21c2)

src/stream-tcp-reassemble.c

index b426f00b6391020eb4b876c915ebb8716ef90f4f..29d06c7febd1870c70c9a782380f6bbdb5e1ddb3 100644 (file)
@@ -1846,7 +1846,11 @@ int StreamTcpReassembleHandleSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_
     } else if (p->tcph->th_flags & TH_RST) { // accepted rst
         dir = UPDATE_DIR_PACKET;
     } else if ((p->tcph->th_flags & TH_FIN) && ssn->state > TCP_TIME_WAIT) {
-        dir = UPDATE_DIR_PACKET;
+        if (p->tcph->th_flags & TH_ACK) {
+            dir = UPDATE_DIR_BOTH;
+        } else {
+            dir = UPDATE_DIR_PACKET;
+        }
     } else if (ssn->state == TCP_CLOSED) {
         dir = UPDATE_DIR_BOTH;
     }