- If recv_files() is sent the index of a directory, complain about it
[rsync/rsync.git] / receiver.c
index 9d1007f..565fa9d 100644 (file)
@@ -57,17 +57,24 @@ extern struct filter_list_struct server_filter_list;
 void delete_files(struct file_list *flist)
 {
        struct file_list *dir_list;
-       char fbuf[MAXPATHLEN];
-       char *argv[1];
+       char *argv[1], fbuf[MAXPATHLEN];
        int j;
 
+       if (io_error && !(lp_ignore_errors(module_id) || ignore_errors)) {
+               rprintf(FINFO,
+                       "IO error encountered -- skipping file deletion\n");
+               return;
+       }
+
        for (j = 0; j < flist->count; j++) {
                if (!(flist->files[j]->flags & FLAG_DEL_START)
                    || !S_ISDIR(flist->files[j]->mode))
                        continue;
 
                argv[0] = f_name_to(flist->files[j], fbuf);
-               dir_list = send_file_list(-1, 1, argv);
+
+               if (!(dir_list = send_file_list(-1, 1, argv)))
+                       continue;
 
                delete_missing(flist, dir_list, fbuf);
 
@@ -336,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 */
@@ -355,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)
@@ -375,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) {