Skip to content

Commit f065d00

Browse files
committed
BUG/MEDIUM: mux-h2: Don't send RST_STREAM frame for streams with no ID
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
1 parent 4fd6d15 commit f065d00

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/mux_h2.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2366,8 +2366,10 @@ static int h2s_send_rst_stream(struct h2c *h2c, struct h2s *h2s)
23662366

23672367
/* RFC7540#5.4.2: To avoid looping, an endpoint MUST NOT send a
23682368
* RST_STREAM in response to a RST_STREAM frame.
2369+
*
2370+
* if h2s is not assigned yet (id == 0), don't send a RST_STREAM frame.
23692371
*/
2370-
if (h2c->dsi == h2s->id && h2c->dft == H2_FT_RST_STREAM) {
2372+
if ((h2s->id == 0) || (h2c->dsi == h2s->id && h2c->dft == H2_FT_RST_STREAM)) {
23712373
ret = 1;
23722374
goto ignore;
23732375
}

0 commit comments

Comments
 (0)