]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: hq-interop: fix transcoding of wrapping response buffer
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 29 Jun 2026 07:54:22 +0000 (09:54 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 29 Jun 2026 14:04:57 +0000 (16:04 +0200)
The below patch has implemented support for response wrapping in HTTP/0.9
transcoder, similar to what is already performed in HTTP/3.

  1e144c488c612092067e07f18618482c64d33d17
  BUG/MINOR: hq-interop: support response buffer wrapping

However, some bits were incorrectly written and the transcoding would
not be able to handle all of the wrapping data in one pass, despite no
crash possible. This patch fixes these, so that a wrapping response can
be handled in a single pass by the HTTP/0.9 transcoder if there is
enough room in the output HTX buffer.

This should fix github issue #3430.

This should be backported up to 3.3.

src/hq_interop.c

index 3868cb2c436f94bbf19b374b5018fc6edb25d1a6..a6ccfbddd6408322934d2c7f27084e51c48f1460 100644 (file)
@@ -116,7 +116,7 @@ static ssize_t hq_interop_rcv_buf_res(struct qcs *qcs, struct buffer *b, int fin
        struct htx_sl *sl;
        struct buffer *htx_buf;
        const unsigned int flags = HTX_SL_F_VER_11|HTX_SL_F_XFER_LEN;
-       size_t to_copy = b_contig_data(b, 0);
+       size_t to_copy = b_data(b);
        size_t htx_sent = 0;
        uint32_t htx_space;
        char *head;
@@ -158,7 +158,7 @@ static ssize_t hq_interop_rcv_buf_res(struct qcs *qcs, struct buffer *b, int fin
                        fin = 0;
                }
 
-               if (b_head(b) + to_copy > b_wrap(b)) {
+               if (head + to_copy > b_wrap(b)) {
                        size_t contig = b_wrap(b) - head;
                        htx_sent = htx_add_data(htx, ist2(b_head(b), contig));
                        if (htx_sent < contig) {