X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/0b91056090d768c4bdc6aa83d929d09416d34e89..dd04a03440be7c04ec7c3005d5fd92ec03311358:/util.c diff --git a/util.c b/util.c index 15cf2bcd..013d62ad 100644 --- a/util.c +++ b/util.c @@ -162,7 +162,13 @@ int piped_child(char **command,int *f_in,int *f_out) void out_of_memory(char *str) { - fprintf(FERROR,"out of memory in %s\n",str); + fprintf(FERROR,"ERROR: out of memory in %s\n",str); + exit_cleanup(1); +} + +void overflow(char *str) +{ + fprintf(FERROR,"ERROR: buffer overflow in %s\n",str); exit_cleanup(1); } @@ -170,24 +176,28 @@ void out_of_memory(char *str) int set_modtime(char *fname,time_t modtime) { + extern int dry_run; + if (dry_run) return 0; + { #ifdef HAVE_UTIMBUF - struct utimbuf tbuf; - tbuf.actime = time(NULL); - tbuf.modtime = modtime; - return utime(fname,&tbuf); + struct utimbuf tbuf; + tbuf.actime = time(NULL); + tbuf.modtime = modtime; + return utime(fname,&tbuf); #elif defined(HAVE_UTIME) - time_t t[2]; - t[0] = time(NULL); - t[1] = modtime; - return utime(fname,t); + time_t t[2]; + t[0] = time(NULL); + t[1] = modtime; + return utime(fname,t); #else - struct timeval t[2]; - t[0].tv_sec = time(NULL); - t[0].tv_usec = 0; - t[1].tv_sec = modtime; - t[1].tv_usec = 0; - return utimes(fname,t); + struct timeval t[2]; + t[0].tv_sec = time(NULL); + t[0].tv_usec = 0; + t[1].tv_sec = modtime; + t[1].tv_usec = 0; + return utimes(fname,t); #endif + } } @@ -310,13 +320,13 @@ int copy_file(char *source, char *dest, mode_t mode) return -1; } - if (unlink(dest) && errno != ENOENT) { + if (do_unlink(dest) && errno != ENOENT) { fprintf(FERROR,"unlink %s: %s\n", dest,strerror(errno)); return -1; } - ofd = open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode); + ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode); if (ofd < 0) { fprintf(FERROR,"open %s: %s\n", dest,strerror(errno));