damn, I had implicitly assumed signed characters when writing the
[rsync/rsync.git] / rsync.c
diff --git a/rsync.c b/rsync.c
index bcb101a..77ad9d7 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -234,9 +234,9 @@ static int set_perms(char *fname,struct file_struct *file,struct stat *st,
   if ((am_root && preserve_uid && st->st_uid != file->uid) || 
       (preserve_gid && st->st_gid != file->gid)) {
     updated = 1;
-    if (chown(fname,
-             (am_root&&preserve_uid)?file->uid:-1,
-             preserve_gid?file->gid:-1) != 0) {
+    if (lchown(fname,
+              (am_root&&preserve_uid)?file->uid:-1,
+              preserve_gid?file->gid:-1) != 0) {
       if (verbose>1 || preserve_uid)
        fprintf(FERROR,"chown %s : %s\n",fname,strerror(errno));
       return updated;
@@ -535,7 +535,7 @@ static void delete_files(struct file_list *flist)
   if (!(local_file_list = send_file_list(-1,1,&dot)))
     return;
 
-  for (i=local_file_list->count;i>=0;i--) {
+  for (i=local_file_list->count-1;i>=0;i--) {
     if (!local_file_list->files[i].name) continue;
     if (-1 == flist_find(flist,&local_file_list->files[i])) {
       delete_one(&local_file_list->files[i]);