From 8f650c369dbe1d6db3538c8fd16ace636c571fea Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 21 Nov 2017 19:36:21 +0100 Subject: [PATCH] BUG/MEDIUM: h2: properly report connection errors in headers and data handlers We used to return >0 indicating a success when an error was present on the connection, preventing the caller from detecting and handling it. This for example happens when sending too many headers in a frame, making the request impossible to decompress. --- src/mux_h2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mux_h2.c b/src/mux_h2.c index 51da752eb2..3ebda26d88 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1505,6 +1505,9 @@ static int h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s) goto conn_err; } + if (h2c->st0 >= H2_CS_ERROR) + return 0; + if (h2s->st >= H2_SS_ERROR) { /* stream error : send RST_STREAM */ h2c->st0 = H2_CS_FRAME_A; @@ -1577,12 +1580,16 @@ static int h2c_frt_handle_data(struct h2c *h2c, struct h2s *h2s) } h2s->cs->data_cb->recv(h2s->cs); + if (h2s->cs->data_cb->wake(h2s->cs) < 0) { /* cs has just been destroyed, we have to kill h2s. */ error = H2_ERR_STREAM_CLOSED; goto strm_err; } + if (h2c->st0 >= H2_CS_ERROR) + return 0; + if (h2s->st >= H2_SS_ERROR) { /* stream error : send RST_STREAM */ h2c->st0 = H2_CS_FRAME_A; -- 2.47.3