]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h2: Don't send RST_STREAM frame for streams with no ID
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 15 Nov 2024 09:25:20 +0000 (10:25 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 15 Nov 2024 09:34:47 +0000 (10:34 +0100)
On server side, the H2 stream is first created with an unassigned ID (ID ==
0). Its ID is assigned when the request is emitted, before formatting the
HEADERS frame. However, the session may be aborted during that stage. We
must take care to not emit RST_STREAM frame for this stream, because it does
not exist yet for the server.

It is especially important to do so because, depending on the timing, it may
also happens before the H2 PREFACE was sent.

This patch must be backported to all stable versions. It is related to issue

src/mux_h2.c

index 8910a909acc384e750ad6d93fea6bd406f3adb0b..131db2f77f82ac31ade5c3e30760651709781415 100644 (file)
@@ -2366,8 +2366,10 @@ static int h2s_send_rst_stream(struct h2c *h2c, struct h2s *h2s)
 
        /* RFC7540#5.4.2: To avoid looping, an endpoint MUST NOT send a
         * RST_STREAM in response to a RST_STREAM frame.
+        *
+        * if h2s is not assigned yet (id == 0), don't send a RST_STREAM frame.
         */
-       if (h2c->dsi == h2s->id && h2c->dft == H2_FT_RST_STREAM) {
+       if ((h2s->id == 0) || (h2c->dsi == h2s->id && h2c->dft == H2_FT_RST_STREAM)) {
                ret = 1;
                goto ignore;
        }