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

index 561f7685cc18c983dcba144410dd064ec615d815..baf80b7f5cbc0aee625d8a0fb0087933e41d81af 100644 (file)
@@ -1097,7 +1097,9 @@ int __safe_mount_beneath_at(int beneath_fd, const char *src, const char *dst, co
        target_fd = openat2(beneath_fd, dst, &how, sizeof(how));
        if (target_fd < 0)
                return -errno;
-       snprintf(tgt_buf, sizeof(tgt_buf), "/proc/self/fd/%d", target_fd);
+       ret = snprintf(tgt_buf, sizeof(tgt_buf), "/proc/self/fd/%d", target_fd);
+       if (ret < 0 || ret >= sizeof(tgt_buf))
+               return -EIO;
 
        if (!is_empty_string(src_buf))
                ret = mount(src_buf, tgt_buf, fstype, flags, data);