]> git.proxmox.com Git - mirror_lxc.git/commitdiff
utils: fix unchecked return value
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 9 Dec 2020 10:49:55 +0000 (11:49 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 15 Dec 2020 11:04:08 +0000 (12:04 +0100)
Fixes: Coverity 1465853
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/utils.c

index 05892571c4b6242a4a629aea48cf1ae380e845a7..b306ef25d7b3cb421721384c2e9d1fb75bd70afc 100644 (file)
@@ -1094,7 +1094,9 @@ int __safe_mount_beneath_at(int beneath_fd, const char *src, const char *dst, co
                source_fd = openat2(beneath_fd, src, &how, sizeof(how));
                if (source_fd < 0)
                        return -errno;
-               snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", source_fd);
+               ret = snprintf(src_buf, sizeof(src_buf), "/proc/self/fd/%d", source_fd);
+               if (ret < 0 || ret >= sizeof(src_buf))
+                       return -EIO;
        } else {
                src_buf[0] = '\0';
        }