]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: h1-htx: Disable 0-copy for buffers of different size
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 10 Feb 2026 14:24:54 +0000 (15:24 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 18 Feb 2026 12:26:21 +0000 (13:26 +0100)
When a message payload is parsed, it is possible to swap buffers. We must
only take care both buffers have same size. It will be mandatory when the
large buffers support on channels will be added.

src/h1_htx.c

index 1f806a76e37d4714ca9f6c9c1d0c1ca0471a2220..b956747c2886ab1107424f1ea68480aa89920dc9 100644 (file)
@@ -464,9 +464,10 @@ static size_t h1_copy_msg_data(struct htx **dsthtx, struct buffer *srcbuf, size_
         *   - count == srcbuf->data
         *   - srcbuf->head == sizeof(struct htx)
         *   => we can swap the buffers and place an htx header into
-        *      the target buffer instead
+        *      the target buffer instead (for buffers of same size)
         */
-       if (unlikely(htx_is_empty(tmp_htx) && count == b_data(srcbuf) &&
+       if (unlikely(b_size(srcbuf) == b_size(htxbuf) &&
+                    htx_is_empty(tmp_htx) && count == b_data(srcbuf) &&
                     !ofs && b_head_ofs(srcbuf) == sizeof(struct htx))) {
                void *raw_area = srcbuf->area;
                void *htx_area = htxbuf->area;