]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
file_utils: fix config file parsing 3582/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 17 Nov 2020 21:34:05 +0000 (22:34 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 17 Nov 2020 21:34:05 +0000 (22:34 +0100)
We accidently used the "bytes_to_write" variable after we've written all the
bytes at which point it is guaranteed to be 0. Let's use the "bytes_read"
variable instead.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/file_utils.c

index 3b4bffb3990a4c227a9727dfc1fd555068060446..a8d9aaf3046c5587ca55a4e3c7f68504c094bc23 100644 (file)
@@ -399,6 +399,7 @@ ssize_t __fd_to_fd(int from, int to)
                        break;
 
                bytes_to_write = (size_t)bytes_read;
+               total_bytes += bytes_read;
                do {
                        ssize_t bytes_written;
 
@@ -409,7 +410,6 @@ ssize_t __fd_to_fd(int from, int to)
                        bytes_to_write -= bytes_written;
                        p += bytes_written;
                } while (bytes_to_write > 0);
-               total_bytes += bytes_to_write;
        }
 
        return total_bytes;