X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/73cb6738b33846130c21f2903b2200fa3f1903ab..a76ba8b4257cc75e99c71da7f44c5e75393a3d43:/options.c diff --git a/options.c b/options.c index 9074e06e..71fda24f 100644 --- a/options.c +++ b/options.c @@ -1044,7 +1044,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) goto options_rejected; dir = cp + (*cp == '/' ? module_dirlen : 0); clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS); - rej = check_filter(&daemon_filter_list, dir, 0) < 0; + rej = check_filter(&daemon_filter_list, FLOG, dir, 0) < 0; free(cp); if (rej) goto options_rejected; @@ -1275,7 +1275,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) } } - if (human_readable && argc == 2) { + if (human_readable && argc == 2 && !am_server) { /* Allow the old meaning of 'h' (--help) on its own. */ usage(FINFO); exit_cleanup(0); @@ -1387,7 +1387,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) xfer_dirs = 1; } - if (argc < 2 && !read_batch) + if (argc < 2 && !read_batch && !am_server) list_only |= 1; if (xfer_dirs >= 4) { @@ -1462,7 +1462,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) goto options_rejected; dir = tmpdir + (*tmpdir == '/' ? module_dirlen : 0); clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS); - if (check_filter(elp, dir, 1) < 0) + if (check_filter(elp, FLOG, dir, 1) < 0) goto options_rejected; } if (backup_dir) { @@ -1471,7 +1471,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) goto options_rejected; dir = backup_dir + (*backup_dir == '/' ? module_dirlen : 0); clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS); - if (check_filter(elp, dir, 1) < 0) + if (check_filter(elp, FLOG, dir, 1) < 0) goto options_rejected; } } @@ -1667,7 +1667,7 @@ int parse_arguments(int *argc_p, const char ***argv_p) goto options_rejected; dir = files_from + (*files_from == '/' ? module_dirlen : 0); clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS); - if (check_filter(&daemon_filter_list, dir, 0) < 0) + if (check_filter(&daemon_filter_list, FLOG, dir, 0) < 0) goto options_rejected; } filesfrom_fd = open(files_from, O_RDONLY|O_BINARY); @@ -1808,25 +1808,40 @@ void server_options(char **args, int *argc_p) if (do_compression) argstr[x++] = 'z'; - /* We make use of the -e option to let the server know about any - * pre-release protocol version && some behavior flags. */ - argstr[x++] = 'e'; + set_allow_inc_recurse(); + + /* Checking the pre-negotiated value allows --protocol=29 override. */ + if (protocol_version >= 30) { + /* We make use of the -e option to let the server know about + * any pre-release protocol version && some behavior flags. */ + argstr[x++] = 'e'; #if SUBPROTOCOL_VERSION != 0 - if (protocol_version == PROTOCOL_VERSION) { - x += snprintf(argstr+x, sizeof argstr - x, - "%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION); - } else + if (protocol_version == PROTOCOL_VERSION) { + x += snprintf(argstr+x, sizeof argstr - x, + "%d.%d", + PROTOCOL_VERSION, SUBPROTOCOL_VERSION); + } else #endif - argstr[x++] = '.'; - set_allow_inc_recurse(); - if (allow_inc_recurse) - argstr[x++] = 'i'; + argstr[x++] = '.'; + if (allow_inc_recurse) + argstr[x++] = 'i'; #if defined HAVE_LUTIMES && defined HAVE_UTIMES - argstr[x++] = 'L'; + argstr[x++] = 'L'; +#endif +#ifdef ICONV_OPTION + argstr[x++] = 's'; #endif + } + + if (x >= (int)sizeof argstr) { /* Not possible... */ + rprintf(FERROR, "argstr overflow in server_options().\n"); + exit_cleanup(RERR_MALLOC); + } + argstr[x] = '\0'; - args[ac++] = argstr; + if (x > 1) + args[ac++] = argstr; #ifdef ICONV_OPTION if (iconv_opt) { @@ -2008,7 +2023,6 @@ void server_options(char **args, int *argc_p) * and it may be an older version that doesn't know this * option, so don't send it if client is the sender. */ - int i; for (i = 0; i < basis_dir_cnt; i++) { args[ac++] = dest_option; args[ac++] = basis_dir[i]; @@ -2048,6 +2062,11 @@ void server_options(char **args, int *argc_p) else if (remove_source_files) args[ac++] = "--remove-sent-files"; + if (ac > MAX_SERVER_ARGS) { /* Not possible... */ + rprintf(FERROR, "argc overflow in server_options().\n"); + exit_cleanup(RERR_MALLOC); + } + *argc_p = ac; return;