From: Christian Brauner Date: Wed, 28 Oct 2020 03:03:31 +0000 (+0100) Subject: conf: check snprint return value X-Git-Tag: lxc-5.0.0~344^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ddf34f7a037325565b8cf8ff995cbf573f9932e;p=thirdparty%2Flxc.git conf: check snprint return value Fixes: Coverity 1465854 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 259d3766a..c258d0b4c 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1207,7 +1207,9 @@ static int lxc_fill_autodev(const struct lxc_rootfs *rootfs) if (ret < 0) { const char *mntpt = rootfs->path ? rootfs->mount : NULL; if (errno == ENOSYS) { - snprintf(path, sizeof(path), "%s/dev/%s", mntpt, device->name); + ret = snprintf(path, sizeof(path), "%s/dev/%s", mntpt, device->name); + if (ret < 0 || ret >= sizeof(path)) + return log_error(-1, "Failed to create device path for %s", device->name); ret = safe_mount(hostpath, path, 0, MS_BIND, NULL, rootfs->path ? rootfs->mount : NULL); } }