]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: h2: don't switch the state to HREM before end of DATA frame
authorWilly Tarreau <w@1wt.eu>
Mon, 11 Dec 2017 17:45:08 +0000 (18:45 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 14 Dec 2017 12:43:52 +0000 (13:43 +0100)
We used to switch the stream's state to HREM when seeing and ES bit on
the DATA frame before actually being able to process that frame, possibly
resulting in the DATA frame being processed after the stream was seen as
half-closed and possibly being rejected. The state must not change before
the frame is really processed.

Also fixes a harmless typo in the flag name which should have DATA and
not HEADERS in its name (but all values are equal).

Must be backported to 1.8.

src/mux_h2.c

index 672bc8ff360ad11244de4a61c4f5678e172535b1..7731c94f053615bac03f9b79fd7c9fba8129e18a 100644 (file)
@@ -1656,12 +1656,6 @@ static int h2c_frt_handle_data(struct h2c *h2c, struct h2s *h2s)
                goto strm_err;
        }
 
-       /* last frame */
-       if (h2c->dff & H2_F_HEADERS_END_STREAM) {
-               h2s->st = H2_SS_HREM;
-               h2s->flags |= H2_SF_ES_RCVD;
-       }
-
        /* call the upper layers to process the frame, then let the upper layer
         * notify the stream about any change.
         */
@@ -1692,6 +1686,13 @@ static int h2c_frt_handle_data(struct h2c *h2c, struct h2s *h2s)
        if (h2c->st0 == H2_CS_FRAME_P)
                return 0;
 
+
+       /* last frame */
+       if (h2c->dff & H2_F_DATA_END_STREAM) {
+               h2s->st = H2_SS_HREM;
+               h2s->flags |= H2_SF_ES_RCVD;
+       }
+
        return 1;
 
  conn_err: