]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: check snprint return value
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 28 Oct 2020 03:03:31 +0000 (04:03 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 28 Oct 2020 03:03:31 +0000 (04:03 +0100)
Fixes: Coverity 1465854
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 259d3766ab24d6fb1d8d5cc61a219dcd7a4e99b4..c258d0b4c5f444a95d2bb9a0cec7e9109cb6d63a 100644 (file)
@@ -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);
                        }
                }