]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: buffers: Fix b_slow_realign when a buffer is realign without output
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 6 Aug 2018 13:43:12 +0000 (15:43 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 6 Aug 2018 13:56:40 +0000 (15:56 +0200)
When b_slow_realign is called with the <output> parameter equal to 0, the
buffer's head, after the realign, must be set to 0. It was errornously set to
the buffer's size, because there was no test on the value of <output>.

include/common/buf.h

index 6d461111250fa52c39c11375c30b99180d441a7b..96472622ec9ac1babb5843fe09246d4aebcc35f4 100644 (file)
@@ -472,7 +472,7 @@ static inline void b_slow_realign(struct buffer *b, char *swap, size_t output)
        memcpy(b_orig(b), swap, b_data(b) - output);
        memcpy(b_wrap(b) - output, swap + b_size(b) - output, output);
 
-       b->head = b_size(b) - output;
+       b->head = (output ? b_size(b) - output : 0);
 }
 
 /* b_putchar() : tries to append char <c> at the end of buffer <b>. Supports