]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: make buffers append function more robust
authorKarel Zak <kzak@redhat.com>
Wed, 14 Apr 2021 14:25:30 +0000 (16:25 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 14 Apr 2021 14:25:30 +0000 (16:25 +0200)
Fixes: https://github.com/karelzak/util-linux/issues/1279
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/buffer.c

index d376e8fb8144933476d33af5e762085cf4aaf77b..8a313791fa176926ea34fdad34f9d4f5de1a3f33 100644 (file)
@@ -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);