]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: haterm: fix the response body phase on short writes
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 4 Nov 2026 15:14:28 +0000 (16:14 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 4 Nov 2026 15:30:23 +0000 (16:30 +0100)
hstream_add_ff_data() computed the offset of the next body byte as
(req_size - len) % modulo, where <len> is the length offered by the mux
for that call. A short write or a partially filled output buffer makes it
smaller than the number of bytes still to send, so the offset no longer
matched what had already been emitted: the repeating pattern jumped and
the peer received a corrupted body, which happened as soon as a proxy read
the response with its own buffer boundaries. Use hs->to_write instead.

Introduced with ecf36f2ca ("MEDIUM: haterm: Add support for 0-copy data
forwading and option to disable it"), present only in the development
branch, so no backport is needed.

src/haterm.c

index 654ab4c4748284199bc7d726ebe67b1e96a8992b..26eddc1eab35a39c7f3ffc7a39408eec9a99ab2b 100644 (file)
@@ -563,7 +563,7 @@ static size_t hstream_add_ff_data(struct hstream *hs, struct sedesc *sd, unsigne
                modulo = HS_COMMON_RESPONSE_LINE_SZ;
        }
 
-       offset = (hs->req_size - len) % modulo;
+       offset = (hs->req_size - hs->to_write) % modulo;
        data_ptr = buffer + offset;
        if (len > (unsigned long long)(buffer_len - offset))
                len = (unsigned long long)(buffer_len - offset);