From 621ad9b18956a81df2b676305547c6321179dc7c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 4 Sep 2021 11:46:52 +0200 Subject: Fix errors in copy_file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common.c b/common.c index 5add5a1..e1d4e03 100644 --- a/common.c +++ b/common.c @@ -35,8 +35,8 @@ copy_file(int destfd, const char *destfname, int srcfd, const char *srcfname, in r += (ssize_t)read_off; for (p = ok_off; p < r; p += w) { - w = write(destfd, buf, (size_t)(r - p)); - if (r <= 0) { + w = write(destfd, &buf[p], (size_t)(r - p)); + if (w <= 0) { fprintf(stderr, "%s: write %s: %s\n", argv0, destfname, strerror(errno)); exit(1); } @@ -45,7 +45,7 @@ copy_file(int destfd, const char *destfname, int srcfd, const char *srcfname, in if (!okp) { w = write(destfd, buf, 1); - if (r <= 0) { + if (w <= 0) { fprintf(stderr, "%s: write %s: %s\n", argv0, destfname, strerror(errno)); exit(1); } -- cgit v1.2.3-70-g09d2