]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: use vsnprintf() in more robust way [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 15 Jan 2020 12:59:42 +0000 (13:59 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 15 Jan 2020 12:59:42 +0000 (13:59 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c

index a6944ffe5116da998cf369b9d24aed2c96e03b66..6c536cc1552f4c4a735b4b8782ed058ab8060d10 100644 (file)
@@ -2684,8 +2684,8 @@ int mnt_context_get_generic_excode(int rc, char *buf, size_t bufsz, char *fmt, .
        /* we need to support "%m" */
        errno = rc < 0 ? -rc : rc;
 
-       if (buf)
-               vsnprintf(buf, bufsz, fmt, va);
+       if (buf && bufsz && vsnprintf(buf, bufsz, fmt, va) < 0)
+               *buf = '\0';
 
        switch (errno) {
        case EINVAL: