]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
rexec: check lseek() return value
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 Feb 2021 08:39:21 +0000 (09:39 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 Feb 2021 08:39:21 +0000 (09:39 +0100)
Not really needed buy ok.

Fixes: Coverity: 1472769
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/rexec.c

index 95a038272b167bbab53f8d209c97715b6ea3fb80..ba5cc0fe8b76f8795da457fa8362c7ddd02d262b 100644 (file)
@@ -127,10 +127,13 @@ static void lxc_rexec_as_memfd(char **argv, char **envp, const char *memfd_name)
                sent = lxc_sendfile_nointr(memfd >= 0 ? memfd : tmpfd, fd, NULL,
                                           st.st_size - bytes_sent);
                if (sent < 0) {
-                       /* Fallback to shoveling data between kernel- and
+                       /*
+                        * Fallback to shoveling data between kernel- and
                         * userspace.
                         */
-                       lseek(fd, 0, SEEK_SET);
+                       if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
+                               fprintf(stderr, "Failed to seek to beginning of file");
+
                        if (fd_to_fd(fd, memfd >= 0 ? memfd : tmpfd))
                                break;