aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-09-04 11:46:52 +0200
committerMattias Andrée <maandree@kth.se>2021-09-04 11:46:52 +0200
commit621ad9b18956a81df2b676305547c6321179dc7c (patch)
treec9d46e5b92a1d39fc9b72732dcd9d5866290eda4
parentAdd missing newline to end of error prints (diff)
downloadeditasroot-621ad9b18956a81df2b676305547c6321179dc7c.tar.gz
editasroot-621ad9b18956a81df2b676305547c6321179dc7c.tar.bz2
editasroot-621ad9b18956a81df2b676305547c6321179dc7c.tar.xz
Fix errors in copy_file1.0.1
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--common.c6
1 files 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);
}