From: Christian Brauner Date: Wed, 28 Oct 2020 03:04:42 +0000 (+0100) Subject: utils: check snprintf return value X-Git-Tag: lxc-5.0.0~344^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dde733e5a049e695885d733eb98795b0eddbd74;p=thirdparty%2Flxc.git utils: check snprintf return value Fixes: Coverity 1465853 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/utils.c b/src/lxc/utils.c index 561f7685c..baf80b7f5 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -1097,7 +1097,9 @@ int __safe_mount_beneath_at(int beneath_fd, const char *src, const char *dst, co target_fd = openat2(beneath_fd, dst, &how, sizeof(how)); if (target_fd < 0) return -errno; - snprintf(tgt_buf, sizeof(tgt_buf), "/proc/self/fd/%d", target_fd); + ret = snprintf(tgt_buf, sizeof(tgt_buf), "/proc/self/fd/%d", target_fd); + if (ret < 0 || ret >= sizeof(tgt_buf)) + return -EIO; if (!is_empty_string(src_buf)) ret = mount(src_buf, tgt_buf, fstype, flags, data);