]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MAJOR: buffer: fix incorrect check in __b_putblk()
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 17:00:20 +0000 (19:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Sep 2018 18:01:14 +0000 (20:01 +0200)
This function was split in two at commit f7d0447 ("MINOR: buffers:
split b_putblk() into __b_putblk()") but it's wrong, the first half's
length is not adjusted to the requested size so it copies more than
desired.

This is purely 1.9-specific, no backport is needed.

include/common/buf.h

index 96472622ec9ac1babb5843fe09246d4aebcc35f4..a1355e653e66c07ff75aa7613fce3989624e7a20 100644 (file)
@@ -494,6 +494,9 @@ static inline void __b_putblk(struct buffer *b, const char *blk, size_t len)
 {
        size_t half = b_contig_space(b);
 
+       if (half > len)
+               half = len;
+
        memcpy(b_tail(b), blk, half);
 
        if (len > half)