]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream/async: fix session setup issues
authorVictor Julien <victor@inliniac.net>
Thu, 30 Oct 2014 09:16:40 +0000 (10:16 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 30 Oct 2014 09:16:40 +0000 (10:16 +0100)
For these 2 cases:

1. Missing SYN:
-> syn <= missing
<- syn/ack
-> ack
-> data

2. Missing SYN and 3whs ACK:
-> syn <= missing
<- syn/ack
-> ack <= missing
-> data

Fix session pickup. The next_win settings weren't correctly set, so that
packets were rejected.

Bug 1190.

src/stream-tcp.c

index 844d8e176376bdd58ac4d3ed43b38a401b963b77..76b256bc998685b89ab9e6c99eb63043af4fbd09 100644 (file)
@@ -850,6 +850,8 @@ static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
         ssn->client.last_ack = TCP_GET_ACK(p);
         ssn->server.last_ack = TCP_GET_SEQ(p);
 
+        ssn->server.next_win = ssn->server.last_ack + ssn->server.window;
+
         /** If the client has a wscale option the server had it too,
          *  so set the wscale for the server to max. Otherwise none
          *  will have the wscale opt just like it should. */
@@ -1768,7 +1770,8 @@ static int StreamTcpPacketStateSynRecv(ThreadVars *tv, Packet *p,
             ssn->server.next_win = ssn->server.last_ack + ssn->server.window;
 
             if (ssn->flags & STREAMTCP_FLAG_MIDSTREAM) {
-                ssn->client.window = TCP_GET_WINDOW(p);
+                ssn->client.window = TCP_GET_WINDOW(p) << ssn->client.wscale;
+                ssn->client.next_win = ssn->client.last_ack + ssn->client.window;
                 ssn->server.next_win = ssn->server.last_ack +
                     ssn->server.window;
                 /* window scaling for midstream pickups, we can't do much