From 363c745569b6ffd8f095d2b7758131d08aa27219 Mon Sep 17 00:00:00 2001 From: Olivier Houchard Date: Wed, 26 Sep 2018 15:09:58 +0200 Subject: [PATCH] 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. --- include/common/buf.h | 2 +- src/channel.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) && -- 2.47.3