From: Willy Tarreau Date: Wed, 5 Sep 2018 17:00:20 +0000 (+0200) Subject: BUG/MAJOR: buffer: fix incorrect check in __b_putblk() X-Git-Tag: v1.9-dev2~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec3750c59068f1ac2c226c33b7e424f1151d49d3;p=thirdparty%2Fhaproxy.git BUG/MAJOR: buffer: fix incorrect check in __b_putblk() 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. --- diff --git a/include/common/buf.h b/include/common/buf.h index 96472622ec..a1355e653e 100644 --- a/include/common/buf.h +++ b/include/common/buf.h @@ -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)