]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: improve last_ack validation check
authorVictor Julien <vjulien@oisf.net>
Fri, 22 Apr 2022 16:27:15 +0000 (18:27 +0200)
committerJeff Lucovsky <jeff@lucovsky.org>
Sun, 29 May 2022 19:23:24 +0000 (15:23 -0400)
If a packet after the initialization would come with ACK flag set
but a ACK value of 0, the last_ack tracking could get confused. Fix
this by not checking for 0 but instead checking if the ACK flag
has been seen.

Bug: #4549.
(cherry picked from commit 1f43e1477f3c5781381e75f4bed918cbc6c18dfd)

src/stream-tcp-reassemble.h

index 275c87d973537e6a1bcf55ec19a3e5226f7153a4..e2f388eb23a4f957fe7fe365df481749cc3e75a2 100644 (file)
@@ -133,14 +133,8 @@ void StreamTcpReassemblySetMinInspectDepth(TcpSession *ssn, int direction, uint3
 static inline bool STREAM_LASTACK_GT_BASESEQ(const TcpStream *stream)
 {
     /* last ack not yet initialized */
-    if (STREAM_BASE_OFFSET(stream) == 0 && (stream->tcp_flags & TH_ACK) == 0) {
-#ifdef UNITTESTS
-        if (RunmodeIsUnittests() && stream->last_ack == 0)
-            return false;
-#else
+    if (STREAM_BASE_OFFSET(stream) == 0 && (stream->tcp_flags & TH_ACK) == 0)
         return false;
-#endif
-    }
     if (SEQ_GT(stream->last_ack, stream->base_seq))
         return true;
     return false;