Added an "ndx" arg to all the finish_hard_link() calls.
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 29d3040..688117c 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -52,6 +52,7 @@ extern int preserve_devices;
 extern int preserve_specials;
 extern int uid_ndx;
 extern int gid_ndx;
+extern int eol_nulls;
 extern int relative_paths;
 extern int implied_dirs;
 extern int file_extra_cnt;
@@ -63,6 +64,7 @@ extern int copy_unsafe_links;
 extern int protocol_version;
 extern int sanitize_paths;
 extern struct stats stats;
+extern char *filesfrom_host;
 
 extern char curr_dir[MAXPATHLEN];
 
@@ -927,7 +929,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
        if (linkname_len) {
                bp = (char*)file->basename + basename_len;
                if (first_hlink_ndx >= flist->ndx_start) {
-                       struct file_struct *first = flist->files[first_hlink_ndx];
+                       struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
                        memcpy(bp, F_SYMLINK(first), linkname_len);
                } else
                        read_sbuf(f, bp, linkname_len - 1);
@@ -974,7 +976,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
                        bp = tmp_sum;
                }
                if (first_hlink_ndx >= flist->ndx_start) {
-                       struct file_struct *first = flist->files[first_hlink_ndx];
+                       struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
                        memcpy(bp, F_SUM(first), checksum_len);
                } else
                        read_buf(f, bp, checksum_len);
@@ -1641,6 +1643,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
        int64 start_write;
        int use_ff_fd = 0;
        int flags, disable_buffering;
+       int reading_remotely = filesfrom_host != NULL;
+       int rl_nulls = eol_nulls || reading_remotely;
 
        rprintf(FLOG, "building file list\n");
        if (show_filelist_p())
@@ -1681,7 +1685,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
                int is_dot_dir;
 
                if (use_ff_fd) {
-                       if (read_filesfrom_line(filesfrom_fd, fbuf) == 0)
+                       if (read_line(filesfrom_fd, fbuf, sizeof fbuf, !reading_remotely, rl_nulls) == 0)
                                break;
                        sanitize_path(fbuf, fbuf, "", 0, NULL);
                } else {