]> git.kaiwu.me - haproxy.git/commitdiff
MEDIUM: mux-h2: don't report EOM on a short content-length message
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 25 Aug 2026 15:10:28 +0000 (17:10 +0200)
committerOlivier Houchard <cognet@ci0.org>
Tue, 25 Aug 2026 15:53:46 +0000 (17:53 +0200)
If we received an end of stream, but we ended up getting less than
Content-Length, then do not broadcast EOM, we never got the whole
message.
This is more hardening, to make sure everything is consistent across the
whole stream.

This should be backported up to 2.8.

src/mux_h2.c

index 7704de822e564abdaaa7a294339f3df9b1c524ef..92ababe061f0a18d20d555544235c9fcf8da0c4f 100644 (file)
@@ -6611,9 +6611,18 @@ try_again:
                 * EOM was already reported.
                 */
                if ((h2c->flags & H2_CF_IS_BACK) || !(h2s->flags & H2_SF_TUNNEL_ABRT)) {
-                       /* htx may be empty if receiving an empty DATA frame. */
-                       if (!htx_set_eom(htx))
-                               goto fail;
+                       /*
+                        * Do not report end of message if we had a
+                        * Content-Length, but we got less than that, otherwise
+                        * the other mux will consider it complete when it
+                        * should not.
+                        */
+                       if (!(h2s->flags & H2_SF_DATA_CLEN) || !h2s->body_len ||
+                           ((h2c->flags & H2_CF_IS_BACK) && (h2s->flags & H2_SF_BODYLESS_RESP))) {
+                               /* htx may be empty if receiving an empty DATA frame. */
+                               if (!htx_set_eom(htx))
+                                       goto fail;
+                       }
                }
        }