]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proxy: Fix input data copy when an error is captured
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 6 Jan 2020 10:37:00 +0000 (11:37 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 6 Jan 2020 12:58:30 +0000 (13:58 +0100)
In proxy_capture_error(), input data are copied in the error snapshot. The copy
must take care of the data wrapping. But the length of the first block is
wrong. It should be the amount of contiguous input data that can be copied
starting from the input's beginning. But the mininum between the input length
and the buffer size minus the input length is used instead. So it is a problem
if input data are wrapping or if more than the half of the buffer is used by
input data.

This patch must be backported as far as 1.9.

src/proxy.c

index 9448d1a3e7cc221efc1b5890594b312a3ebffde1..8720b2880a330dd582d96314649d169fe889c401 100644 (file)
@@ -1545,7 +1545,7 @@ void proxy_capture_error(struct proxy *proxy, int is_back,
        es->buf_len = buf_len;
        es->ev_id   = ev_id;
 
-       len1 = b_size(buf) - buf_len;
+       len1 = b_size(buf) - b_peek_ofs(buf, buf_out);
        if (len1 > buf_len)
                len1 = buf_len;