]> git.kaiwu.me - haproxy.git/commitdiff
MEDIUM: mux-h1: Harden test for short data at end of stream
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 3 Sep 2026 11:39:04 +0000 (13:39 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 3 Sep 2026 12:13:46 +0000 (14:13 +0200)
Commit 75dd2c18dda29f9893574ef982ddf66de16f0408 made it so if we had a
content-length, and we sent less data than expected, we'd make sure to
close the connection and to not reuse it, otherwise the server would
still expect more data. But it can also happen with no content-length,
with chunked data. There is absolutely no reason we reach that code
while still expecting more data, so just always consider that an error,
no matter if we have content-length or not.

This should be backported up to 2.8.

src/mux_h1.c

index eda34f252df6b38257993f423adfce4e2486f2d8..0587b832d86f11c171966eb5979f1b0ae18b8d90 100644 (file)
@@ -1089,8 +1089,8 @@ static void h1s_destroy(struct h1s *h1s)
                 * announced in Content-Length, we have little choice but to
                 * close the connection, as the peer will expect more.
                 */
-               if (((h1s->req.flags & H1_MF_CLEN) && h1s->req.curr_len && !(h1s->flags & H1S_F_BODYLESS_REQ)) ||
-                   ((h1s->res.flags & H1_MF_CLEN) && h1s->res.curr_len && !(h1s->flags & H1S_F_BODYLESS_RESP)))
+               if ((h1s->req.curr_len && !(h1s->flags & H1S_F_BODYLESS_REQ)) ||
+                   (h1s->res.curr_len && !(h1s->flags & H1S_F_BODYLESS_RESP)))
                        h1c->flags |= H1C_F_ERROR;
 
                if (!(h1c->flags & (H1C_F_EOS|H1C_F_ERR_PENDING|H1C_F_ERROR|H1C_F_ABRT_PENDING|H1C_F_ABRTED)) &&  /* No error/read0/abort */