]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h1: Don't emit 0-CRLF chunk in h1_done_ff() when iobuf is empty
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 21 Feb 2024 08:30:46 +0000 (09:30 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 21 Feb 2024 10:49:58 +0000 (11:49 +0100)
A chunk message transferred via zero-copy forwarding in H1 may be
corrupted. This only happens when the chunk size is not known during the
nego stage and when there is nothing to forward when h1_donn_ff() is
called. In this case, we always emit a chunk. Because there is nothing to
forward, a 0-CRLF is emitted in the middle of the message.

The issue occurred with the HTTP stats applet only.

A simple fix is to check the size of data in the iobuf before emitting a new
chunk in h1_done_ff(). However, we still try to send outgoing data because
when this happens, it is most of time because the H1 output buffer is almost
full.

This patch should fix the issue #2453. No backport needed.

src/mux_h1.c

index 15faa4fc3571095ac7b7a78c2515893181bdd909..19fce077e5b3fb0d9ac9bdca4523a7713f411766 100644 (file)
@@ -4602,7 +4602,7 @@ static size_t h1_done_ff(struct stconn *sc)
                if (b_room(&h1c->obuf) == sd->iobuf.offset)
                        h1c->flags |= H1C_F_OUT_FULL;
 
-               if (sd->iobuf.offset) {
+               if (sd->iobuf.data && sd->iobuf.offset) {
                        struct buffer buf = b_make(b_orig(&h1c->obuf), b_size(&h1c->obuf),
                                                   b_peek_ofs(&h1c->obuf, b_data(&h1c->obuf) - sd->iobuf.data + sd->iobuf.offset),
                                                   sd->iobuf.data);