From: Wayne Davison Date: Tue, 27 Apr 2004 19:59:37 +0000 (+0000) Subject: In copy_file(), check len < 0 before checking the close() return values. X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/8b602edda4fecabfc9734707210e3d30f8e8c3f1?ds=sidebyside In copy_file(), check len < 0 before checking the close() return values. --- diff --git a/util.c b/util.c index 5129c35b..9f28148a 100644 --- a/util.c +++ b/util.c @@ -281,6 +281,14 @@ int copy_file(char *source, char *dest, mode_t mode) } } + if (len < 0) { + rprintf(FERROR, "read %s: %s\n", + full_fname(source), strerror(errno)); + close(ifd); + close(ofd); + return -1; + } + if (close(ifd) < 0) { rprintf(FINFO, "close failed on %s: %s\n", full_fname(source), strerror(errno)); @@ -292,12 +300,6 @@ int copy_file(char *source, char *dest, mode_t mode) return -1; } - if (len < 0) { - rprintf(FERROR,"read %s: %s\n", - full_fname(source), strerror(errno)); - return -1; - } - return 0; }