X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/f98c60bfa8c755b59b0299d7e656bbb298b083c5..e0391f8149c1dfe9bfa8660c7825e94fe7c4228a:/options.c diff --git a/options.c b/options.c index cf705dcd..55a77f0f 100644 --- a/options.c +++ b/options.c @@ -88,6 +88,7 @@ int max_delete = 0; int ignore_errors = 0; int modify_window = 0; int blocking_io = -1; +int checksum_seed = 0; unsigned int block_size = 0; @@ -107,6 +108,7 @@ int write_batch = 0; int read_batch = 0; int backup_dir_len = 0; int backup_suffix_len; +unsigned int backup_dir_remainder; char *backup_suffix = NULL; char *tmpdir = NULL; @@ -117,6 +119,7 @@ char *log_format = NULL; char *password_file = NULL; char *rsync_path = RSYNC_PATH; char *backup_dir = NULL; +char backup_dir_buf[MAXPATHLEN]; int rsync_port = RSYNC_PORT; int link_dest = 0; @@ -125,6 +128,7 @@ int quiet = 0; int always_checksum = 0; int list_only = 0; +#define FIXED_CHECKSUM_SEED 32761 #define MAX_BATCH_PREFIX_LEN 256 /* Must be less than MAXPATHLEN-13 */ char *batch_prefix = NULL; @@ -551,11 +555,13 @@ int parse_arguments(int *argc, const char ***argv, int frommain) case OPT_WRITE_BATCH: /* popt stores the filename in batch_prefix for us */ write_batch = 1; + checksum_seed = FIXED_CHECKSUM_SEED; break; case OPT_READ_BATCH: /* popt stores the filename in batch_prefix for us */ read_batch = 1; + checksum_seed = FIXED_CHECKSUM_SEED; break; case OPT_LINK_DEST: @@ -642,16 +648,27 @@ int parse_arguments(int *argc, const char ***argv, int frommain) relative_paths = files_from? 1 : 0; if (!backup_suffix) - backup_suffix = backup_dir? "" : BACKUP_SUFFIX; + backup_suffix = backup_dir ? "" : BACKUP_SUFFIX; backup_suffix_len = strlen(backup_suffix); if (strchr(backup_suffix, '/') != NULL) { rprintf(FERROR, "--suffix cannot contain slashes: %s\n", backup_suffix); exit_cleanup(RERR_SYNTAX); } - if (backup_dir) - backup_dir_len = strlen(backup_dir); - else if (!backup_suffix_len) { + if (backup_dir) { + backup_dir_len = strlcpy(backup_dir_buf, backup_dir, sizeof backup_dir_buf); + backup_dir_remainder = sizeof backup_dir_buf - backup_dir_len; + if (backup_dir_remainder < 32) { + rprintf(FERROR, "the --backup-dir path is WAY too long.\n"); + exit_cleanup(RERR_SYNTAX); + } + if (backup_dir_buf[backup_dir_len - 1] != '/') { + backup_dir_buf[backup_dir_len++] = '/'; + backup_dir_buf[backup_dir_len] = '\0'; + } + if (verbose > 1) + rprintf(FINFO, "backup_dir is %s\n", backup_dir_buf); + } else if (!backup_suffix_len) { rprintf(FERROR, "--suffix cannot be a null string without --backup-dir\n"); exit_cleanup(RERR_SYNTAX);