From: Olivier Houchard Date: Wed, 26 Sep 2018 13:09:58 +0000 (+0200) Subject: BUG/MEDIUM: buffers: Make sure we don't wrap in ci_insert_line2/b_rep_blk. X-Git-Tag: v1.9-dev4~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=363c745569b6ffd8f095d2b7758131d08aa27219;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: buffers: Make sure we don't wrap in ci_insert_line2/b_rep_blk. 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. --- diff --git a/include/common/buf.h b/include/common/buf.h index 420882026b..d39de7112a 100644 --- a/include/common/buf.h +++ b/include/common/buf.h @@ -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) && diff --git a/src/channel.c b/src/channel.c index 13184ec3ac..3bf5c50428 100644 --- a/src/channel.c +++ b/src/channel.c @@ -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) &&