From: Willy Tarreau Date: Thu, 3 Jan 2019 08:32:20 +0000 (+0100) Subject: BUG/MINOR: mux-h2: mark end-of-stream after processing response HEADERS, not before X-Git-Tag: v2.0-dev1~296 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45ffc0ca347c523671a16698a147b819291dae01;p=thirdparty%2Fhaproxy.git BUG/MINOR: mux-h2: mark end-of-stream after processing response HEADERS, not before When dealing with a server's H2 response, we used to set the end-of-stream flag on the conn_stream and the stream before parsing the response, which is incorrect since we can fail to process this response by lack of room, buffer or anything. The extend of this problem is still limited to a few rare cases, but with trailers it will cause a systematic failure. This fix must be backported to 1.9. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 0c65bbabd6..1b240a942b 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1954,11 +1954,6 @@ static struct h2s *h2c_bck_handle_headers(struct h2c *h2c, struct h2s *h2s) if (b_data(&h2c->dbuf) < h2c->dfl && !b_full(&h2c->dbuf)) return NULL; // incomplete frame - if (h2c->dff & H2_F_HEADERS_END_STREAM) { - h2s->flags |= H2_SF_ES_RCVD; - h2s->cs->flags |= CS_FL_REOS; - } - if (!h2c_decode_headers(h2c, &h2s->rxbuf, &h2s->flags)) return NULL; @@ -1970,6 +1965,11 @@ static struct h2s *h2c_bck_handle_headers(struct h2c *h2c, struct h2s *h2s) h2c->st0 = H2_CS_FRAME_E; } + if (h2c->dff & H2_F_HEADERS_END_STREAM) { + h2s->flags |= H2_SF_ES_RCVD; + h2s->cs->flags |= CS_FL_REOS; + } + if (h2s->cs->flags & CS_FL_ERROR && h2s->st < H2_SS_ERROR) h2s->st = H2_SS_ERROR; else if (h2s->cs->flags & CS_FL_REOS && h2s->st == H2_SS_OPEN)