]> git.proxmox.com Git - mirror_lxc.git/commitdiff
file_utils: allow fd_to_buf() to fail for real
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 19 Feb 2021 13:32:36 +0000 (14:32 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 19 Feb 2021 13:32:36 +0000 (14:32 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/file_utils.c

index 6256540050b57d19010a1b402d94138cfadc5488..6f668988ad70cf5258b988e6dc30ecbd22011f0d 100644 (file)
@@ -455,12 +455,15 @@ int fd_to_buf(int fd, char **buf, size_t *length)
 
                bytes_read = lxc_read_nointr(fd, chunk, sizeof(chunk));
                if (bytes_read < 0)
-                       return 0;
+                       return -errno;
 
                if (!bytes_read)
                        break;
 
-               copy = must_realloc(old, (*length + bytes_read) * sizeof(*old));
+               copy = realloc(old, (*length + bytes_read) * sizeof(*old));
+               if (!copy)
+                       return ret_errno(ENOMEM);
+
                memcpy(copy + *length, chunk, bytes_read);
                *length += bytes_read;
        }