]> git.ipfire.org Git - thirdparty/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>
Thu, 10 Dec 2020 19:39:55 +0000 (20:39 +0100)
Fixes: Coverity 1465853
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/utils.c

index 8c96a860591773bdfd583f207279b68d2153fc99..243dfd33d370104a8710ad15d785f3165226d65e 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';
        }