]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h2: mark end-of-stream after processing response HEADERS, not before
authorWilly Tarreau <w@1wt.eu>
Thu, 3 Jan 2019 08:32:20 +0000 (09:32 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 3 Jan 2019 08:34:19 +0000 (09:34 +0100)
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.

src/mux_h2.c

index 0c65bbabd6bb28a1d5a71ef5ee2fa1004073c0d5..1b240a942b14cc82e770b1b7a47c54ee32c67221 100644 (file)
@@ -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)