From: Christian Brauner Date: Wed, 9 Dec 2020 10:49:55 +0000 (+0100) Subject: utils: fix unchecked return value X-Git-Tag: lxc-5.0.0~330^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=999f5140b7877f0c68d34dc8af635550ff344dee;p=thirdparty%2Flxc.git utils: fix unchecked return value Fixes: Coverity 1465853 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 8c96a8605..243dfd33d 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -1094,7 +1094,9 @@ int __safe_mount_beneath_at(int beneath_fd, const char *src, const char *dst, co source_fd = openat2(beneath_fd, src, &how, sizeof(how)); if (source_fd < 0) return -errno; - snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", source_fd); + ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", source_fd); + if (ret < 0 || ret >= sizeof(src_buf)) + return -EIO; } else { src_buf[0] = '\0'; }