From: Christian Brauner Date: Wed, 9 Dec 2020 10:51:04 +0000 (+0100) Subject: conf: fix unchecked return value X-Git-Tag: lxc-5.0.0~330^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b41ff502ff61ede851c335885c12178dca1e5053;p=thirdparty%2Flxc.git conf: fix unchecked return value Fixes: Coverity: 1465854 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 84d16d774..434104c92 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1201,7 +1201,9 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs) } /* Fallback to bind-mounting the device from the host. */ - snprintf(hostpath, sizeof(hostpath), "/dev/%s", device->name); + ret = snprintf(hostpath, sizeof(hostpath), "/dev/%s", device->name); + if (ret < 0 || (size_t)ret >= sizeof(hostpath)) + return ret_errno(EIO); ret = safe_mount_beneath_at(dev_dir_fd, hostpath, device->name, NULL, MS_BIND, NULL); if (ret < 0) {