From: Willy Tarreau Date: Mon, 11 Dec 2017 17:45:08 +0000 (+0100) Subject: BUG/MEDIUM: h2: don't switch the state to HREM before end of DATA frame X-Git-Tag: v1.9-dev1~585 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4134ba8b0dacfe008a7974a8d31630534030ca7;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: h2: don't switch the state to HREM before end of DATA frame 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. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 672bc8ff36..7731c94f05 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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: