In copy_file(), check len < 0 before checking the close() return values.
authorWayne Davison <wayned@samba.org>
Tue, 27 Apr 2004 19:59:37 +0000 (19:59 +0000)
committerWayne Davison <wayned@samba.org>
Tue, 27 Apr 2004 19:59:37 +0000 (19:59 +0000)
util.c

diff --git a/util.c b/util.c
index 5129c35..9f28148 100644 (file)
--- 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));
        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;
        }
 
                return -1;
        }
 
-       if (len < 0) {
-               rprintf(FERROR,"read %s: %s\n",
-                       full_fname(source), strerror(errno));
-               return -1;
-       }
-
        return 0;
 }
 
        return 0;
 }