]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: flt-trace: consume the whole block size when dumping HTX data
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 10:02:52 +0000 (11:02 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 3 Dec 2026 12:41:07 +0000 (13:41 +0100)
In trace_htx_hexdump(), the remaining length to dump was decremented by
the length of the block value instead of the block size. But the length
is expressed in bytes of the HTX message. For a block without value or
with a value smaller than the block itself, like a NOOP block, the length
was not decremented accordingly and the dump could go beyond the
forwarded data. For instance, with a NOOP block in the middle of the
payload, one extra byte of the next DATA block was dumped.

Now the whole block size, minus the offset, is consumed.

This patch must be backported to 3.5.

src/flt_trace.c

index a51d92867e7e25e61b89faa44121a269844d918a..6a4e114524a8f06e250496e3849bab45da7f80b7 100644 (file)
@@ -143,12 +143,19 @@ trace_htx_hexdump(struct htx *htx, unsigned int offset, unsigned int len)
                        continue;
                }
 
+               /* <len> is a number of bytes in the HTX message, so the whole
+                * block size must be consumed, whatever the length of its value
+                * (e.g. NOOP blocks have no value but a size of 1 byte).
+                */
+               sz -= offset;
+               if (sz > len)
+                       sz = len;
+               len -= sz;
+
                v = htx_get_blk_value(htx, blk);
                v = istadv(v, offset);
                offset = 0;
-
-               v = isttrim(v, len);
-               len -= v.len;
+               v = isttrim(v, sz);
                if (htx_is_data_type(type))
                        trace_hexdump(v);
        }