]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h1: Send a 400-bad-request on shutdown before the first request
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Oct 2023 13:34:04 +0000 (15:34 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 13 Oct 2023 15:16:43 +0000 (17:16 +0200)
Except if we must silently ignore empty connections by enabling
http-ignore-probes or dontlognull options, when a client connection is
closed before the first request, a 400-bad-request response must be sent
with the corresponding log message. However, that is broken since the commit
fc473a6453 ("MEDIUM: mux-h1: Rely on the H1C to deal with shutdown for
reads").

The bug is subtle. Parsing errors are no longer reported on connection errors
before the first request while it should be.

This patch must be backported where the above commit is (as far as 2.7).

src/mux_h1.c

index c01223a65b391f34994fc296317453b3e71fc85c..7405d907d97685d1684d10497c9e6f033125d9f3 100644 (file)
@@ -3580,7 +3580,7 @@ static int h1_process(struct h1c * h1c)
            (h1c->state >= H1_CS_CLOSING && (h1c->flags & H1C_F_SILENT_SHUT) && !b_data(&h1c->obuf))) {
                if (h1c->state != H1_CS_RUNNING) {
                        /* No stream connector or upgrading */
-                       if (h1c->state < H1_CS_RUNNING && !(h1c->flags & (H1C_F_IS_BACK|H1C_F_ERROR))) {
+                       if (h1c->state < H1_CS_RUNNING && !(h1c->flags & (H1C_F_IS_BACK|H1C_F_ABRT_PENDING))) {
                                /* shutdown for reads and no error on the frontend connection: Send an error */
                                if (h1_handle_parsing_error(h1c))
                                        h1_send(h1c);