From 8c2ffaf09553a85be1d2f7d135b959dbb8fa75c8 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Thu, 3 Feb 2005 00:19:40 +0000 Subject: [PATCH] - If recv_files() is sent the index of a directory, complain about it and die. - Moved a few code snippets in recv_files() into better locations. --- receiver.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/receiver.c b/receiver.c index 7f807d96..565fa9d9 100644 --- a/receiver.c +++ b/receiver.c @@ -343,16 +343,27 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, } file = flist->files[i]; + if (S_ISDIR(file->mode)) { + rprintf(FERROR, "[%s] got index of directory: %d\n", + who_am_i(), i); + exit_cleanup(RERR_PROTOCOL); + } stats.current_file_index = i; stats.num_transferred_files++; stats.total_transferred_size += file->length; cleanup_got_literal = 0; - if (local_name) - fname = local_name; - else - fname = f_name_to(file, fbuf); + fname = local_name ? local_name : f_name_to(file, fbuf); + + if (server_filter_list.head + && check_filter(&server_filter_list, fname, 0) < 0) { + rprintf(FERROR, "attempt to hack rsync failed.\n"); + exit_cleanup(RERR_PROTOCOL); + } + + if (verbose > 2) + rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname)); if (dry_run) { if (!am_server && verbose) /* log the transfer */ @@ -362,9 +373,6 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, initial_stats = stats; - if (verbose > 2) - rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname)); - if (read_batch) { while (i > next_gen_i) { if (f_in_name >= 0 && next_gen_i >= 0) @@ -382,13 +390,6 @@ int recv_files(int f_in, struct file_list *flist, char *local_name, next_gen_i = -1; } - if (server_filter_list.head - && check_filter(&server_filter_list, fname, - S_ISDIR(file->mode)) < 0) { - rprintf(FERROR, "attempt to hack rsync failed.\n"); - exit_cleanup(RERR_PROTOCOL); - } - partialptr = partial_dir ? partial_dir_fname(fname) : fname; if (f_in_name >= 0) { -- 2.34.1