1 commit 45e9f3c660c872e93588cf1c0b74c192f2c8c3d5
2 Author: Olivier Houchard <ohouchard@haproxy.com>
3 Date: Wed Sep 26 15:09:58 2018 +0200
5 BUG/MEDIUM: buffers: Make sure we don't wrap in buffer_insert_line2/replace2.
7 In buffer_insert_line2() and buffer_replace2(), we can't afford to wrap,
8 so don't use b_tail to check if we do, directly use b->p + b->i instead.
10 This should be backported to previous versions.
12 (cherry picked from commit 363c745569b6ffd8f095d2b7758131d08aa27219)
13 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
15 [cf: This patch was adapted and its commit message too. Because of the
16 refactoring of the buffer's API in 1.9, the original patch fixes same bug in
17 ci_insert_line2/b_rep_blk.]
19 diff --git a/src/buffer.c b/src/buffer.c
20 index 167b75ae..6ad38a02 100644
23 @@ -107,7 +107,7 @@ int buffer_replace2(struct buffer *b, char *pos, char *end, const char *str, int
25 delta = len - (end - pos);
27 - if (bi_end(b) + delta > b->data + b->size)
28 + if (b->p + b->i + delta > b->data + b->size)
29 return 0; /* no space left */
31 if (buffer_not_empty(b) &&
32 @@ -146,7 +146,7 @@ int buffer_insert_line2(struct buffer *b, char *pos, const char *str, int len)
36 - if (bi_end(b) + delta >= b->data + b->size)
37 + if (b->p + b->i + delta >= b->data + b->size)
38 return 0; /* no space left */
40 if (buffer_not_empty(b) &&