]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: fix unchecked return value
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 9 Dec 2020 10:51:04 +0000 (11:51 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 10 Dec 2020 19:39:55 +0000 (20:39 +0100)
Fixes: Coverity: 1465854
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 84d16d77495771f6c91a1f26001aa31a4d4e3774..434104c927d44c39b9265d7b463a398f42a54024 100644 (file)
@@ -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) {