X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/9f27cd8ca6ccbf1ab4cd8b0b66445535e2573d59..eb0cbdaa90087abb4f17bd86cee359a8fe5cad3d:/util.c diff --git a/util.c b/util.c index 5129c35b..6fe19fcd 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; } @@ -497,7 +499,10 @@ static int exclude_server_path(char *arg) static void glob_expand_one(char *s, char **argv, int *argc, int maxargs) { #if !(defined(HAVE_GLOB) && defined(HAVE_GLOB_H)) - if (!*s) s = "."; + if (maxargs <= *argc) + return; + if (!*s) + s = "."; s = argv[*argc] = strdup(s); exclude_server_path(s); (*argc)++; @@ -506,12 +511,12 @@ static void glob_expand_one(char *s, char **argv, int *argc, int maxargs) glob_t globbuf; int i; - if (!*s) s = "."; + if (!*s) + s = "."; s = argv[*argc] = strdup(s); - if (sanitize_paths) { + if (sanitize_paths) sanitize_path(s, NULL); - } memset(&globbuf, 0, sizeof globbuf); if (!exclude_server_path(s))