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.
This commit is contained in:
Willy Tarreau 2017-11-21 19:36:21 +01:00
parent 358847f026
commit 8f650c369d

View file

@ -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;