]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h2: make sure response HEADERS are not received in other states than...
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Jan 2019 15:55:48 +0000 (16:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Jan 2019 18:37:14 +0000 (19:37 +0100)
RFC7540#5.1 states that these are the only states allowing any frame
type. For response HEADERS frames, we cannot accept that they are
delivered on idle streams of course, so we're left with these two
states only. It is important to test this so that we can remove the
generic CLOSE_STREAM test for such frames in the main loop.

This must be backported to 1.9 (1.8 doesn't have response HEADERS).

src/mux_h2.c

index badd905d1042c7f5e46a6b98051df553e3c77855..c216f5032ece1434ccc4296163b0a1f9c8840cec 100644 (file)
@@ -2039,6 +2039,13 @@ static struct h2s *h2c_bck_handle_headers(struct h2c *h2c, struct h2s *h2s)
        if (h2c->st0 >= H2_CS_ERROR)
                return NULL;
 
+       if (h2s->st != H2_SS_OPEN && h2s->st != H2_SS_HLOC) {
+               /* RFC7540#5.1 */
+               h2s_error(h2s, H2_ERR_STREAM_CLOSED);
+               h2c->st0 = H2_CS_FRAME_E;
+               return NULL;
+       }
+
        if (error <= 0) {
                if (error == 0)
                        return NULL; // missing data