From: Karel Zak Date: Wed, 14 Apr 2021 14:25:30 +0000 (+0200) Subject: libsmartcols: make buffers append function more robust X-Git-Tag: v2.37-rc2~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aac716f50355395ad2ba06524b19f690e321f118;p=thirdparty%2Futil-linux.git libsmartcols: make buffers append function more robust Fixes: https://github.com/karelzak/util-linux/issues/1279 Signed-off-by: Karel Zak --- diff --git a/libsmartcols/src/buffer.c b/libsmartcols/src/buffer.c index d376e8fb81..8a313791fa 100644 --- a/libsmartcols/src/buffer.c +++ b/libsmartcols/src/buffer.c @@ -56,6 +56,8 @@ int buffer_append_data(struct libscols_buffer *buf, const char *str) return -EINVAL; if (!str || !*str) return 0; + if (!buf->cur || !buf->begin) + return -EINVAL; sz = strlen(str); maxsz = buf->bufsz - (buf->cur - buf->begin);