]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: h2: properly report connection errors in headers and data handlers
authorWilly Tarreau <w@1wt.eu>
Tue, 21 Nov 2017 18:36:21 +0000 (19:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 21 Nov 2017 18:36:21 +0000 (19:36 +0100)
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

index 51da752eb2dbe46d96929a8db8c8096ca77fd8d6..3ebda26d88d26b8c851530203568903553ba027d 100644 (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;