]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: buffers: Make sure we don't wrap in ci_insert_line2/b_rep_blk.
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 26 Sep 2018 13:09:58 +0000 (15:09 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Oct 2018 14:11:54 +0000 (16:11 +0200)
In ci_insert_line2() and b_rep_blk(), we can't afford to wrap, so don't use
b_tail() to check if we do, use __b_tail() instead.

This should be backported to previous versions.

include/common/buf.h
src/channel.c

index 420882026b45443c03d1f7615293a7acb8e5b352..d39de7112a1380c43d853dd1b6a3c9d0872eae34 100644 (file)
@@ -578,7 +578,7 @@ static inline int b_rep_blk(struct buffer *b, char *pos, char *end, const char *
 
        delta = len - (end - pos);
 
-       if (b_tail(b) + delta > b_wrap(b))
+       if (__b_tail(b) + delta > b_wrap(b))
                return 0;  /* no space left */
 
        if (b_data(b) &&
index 13184ec3acd4321852e1b1e4ef4369793e65994d..3bf5c50428561dbdd69c22c2b74025f08cf8e72c 100644 (file)
@@ -417,7 +417,7 @@ int ci_insert_line2(struct channel *c, int pos, const char *str, int len)
 
        delta = len + 2;
 
-       if (b_tail(b) + delta >= b_wrap(b))
+       if (__b_tail(b) + delta >= b_wrap(b))
                return 0;  /* no space left */
 
        if (b_data(b) &&