From: Willy Tarreau Date: Tue, 21 Nov 2017 18:36:21 +0000 (+0100) Subject: BUG/MEDIUM: h2: properly report connection errors in headers and data handlers X-Git-Tag: v1.8.0~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8f650c369dbe1d6db3538c8fd16ace636c571fea;p=thirdparty%2Fhaproxy.git 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. --- 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;