Merged in the security fixes from 2.5.7.
[rsync/rsync.git] / hlink.c
diff --git a/hlink.c b/hlink.c
index ea38999..3826ce5 100644 (file)
--- a/hlink.c
+++ b/hlink.c
@@ -57,9 +57,7 @@ void init_hard_links(struct file_list *flist)
        if (hlink_list)
                free(hlink_list);
 
-       if (!(hlink_list =
-             (struct file_struct *) malloc(sizeof(hlink_list[0]) *
-                                           flist->count)))
+       if (!(hlink_list = new_array(struct file_struct, flist->count)))
                out_of_memory("init_hard_links");
 
        for (i = 0; i < flist->count; i++)
@@ -97,6 +95,8 @@ int check_hard_link(struct file_struct *file)
                        low = mid + 1;
        }
 
+       /* XXX: To me this looks kind of dodgy -- why do we use [low]
+        * here and [low-1] below? -- mbp */
        if (hlink_compare(&hlink_list[low], file) != 0)
                return 0;
 
@@ -106,7 +106,7 @@ int check_hard_link(struct file_struct *file)
            file->inode == hlink_list[low - 1].inode) {
                if (verbose >= 2) {
                        rprintf(FINFO, "check_hard_link: \"%s\" is a hard link to file %d, \"%s\"\n",
-                               f_name(file), low, f_name(&hlink_list[low]));
+                               f_name(file), low-1, f_name(&hlink_list[low-1]));
                }
                return 1;
        }