From 8b602edda4fecabfc9734707210e3d30f8e8c3f1 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Tue, 27 Apr 2004 19:59:37 +0000 Subject: [PATCH] In copy_file(), check len < 0 before checking the close() return values. --- util.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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; } -- 2.34.1