From: Karel Zak Date: Wed, 15 Jan 2020 12:59:42 +0000 (+0100) Subject: libmount: use vsnprintf() in more robust way [coverity scan] X-Git-Tag: v2.35~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=810dfb7de6d6a5ddb2c0d72066ba042e117f8a6e;p=thirdparty%2Futil-linux.git libmount: use vsnprintf() in more robust way [coverity scan] Signed-off-by: Karel Zak --- diff --git a/libmount/src/context.c b/libmount/src/context.c index a6944ffe51..6c536cc155 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -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: