From 7d84e2cd65e120146001fa19127f61af0e0d7306 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 17 Nov 2020 22:34:05 +0100 Subject: [PATCH] file_utils: fix config file parsing 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 --- src/lxc/file_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/file_utils.c b/src/lxc/file_utils.c index 3b4bffb39..a8d9aaf30 100644 --- a/src/lxc/file_utils.c +++ b/src/lxc/file_utils.c @@ -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; -- 2.47.2