Two(?) bugs in the xattrs patch

Jay Fenlason
2006-06-10T03:27:54Z

I recently found a bug in the xattrs patch, where it would apply the
wrong xattrs to some files in a transfer.  While looking at the code,
I think I found another one (it sure looks wrong, but I haven't
figured out how to demonstrate it yet).  Anyway, here's the patch:

The first hunk fixes the apparent bug.  The second hunk fixes the
demonstratable bug.

I haven't (yet) looked to see if the acls patch (which I based the
xattrs patch on) has the same bug(s).

			-- JF


--- rsync-2.6.8/patches/#xattrs.diff~	2006-06-09 22:00:05.000000000 -0400
+++ rsync-2.6.8/patches/xattrs.diff	2006-06-09 22:00:38.000000000 -0400
@@ -372,7 +372,7 @@
  transfer.  The resulting value is treated as though it was the permissions
 --- old/xattr.c
 +++ new/xattr.c
-@@ -0,0 +1,523 @@
+@@ -0,0 +1,524 @@
 +/* Extended Attribute support for rsync */
 +/* Copyright (C) 2004 Red Hat, Inc */
 +/* Written by Jay Fenlason, vaguely based on the ACLs patch */
@@ -590,10 +590,10 @@
 +		strcpy(ptr, name);
 +		if (datum_size)
 +			memcpy(ptr + len, datumbuf, datum_size);
-+		x->rxas[curr_rsync_xal.count].name_len = len;
-+		x->rxas[curr_rsync_xal.count].name = ptr;
-+		x->rxas[curr_rsync_xal.count].datum_len = datum_size;
-+		x->rxas[curr_rsync_xal.count].datum = ptr + len;
++		x->rxas[x->count].name_len = len;
++		x->rxas[x->count].name = ptr;
++		x->rxas[x->count].datum_len = datum_size;
++		x->rxas[x->count].datum = ptr + len;
 +		x->count++;
 +	}
 +	if (x->count > 1) {
@@ -656,6 +656,7 @@
 +	rsync_xal_l.count++;
 +	curr_rsync_xal.count = 0;
 +	curr_rsync_xal.alloc = 0;
++	curr_rsync_xal.rxas = NULL;
 +}
 +
 +/* send the make_xattr()-generated xattr list for this flist entry,