rsync: --delete fails with multiple source directories

Wayne Davison wayned at
Sat Jul 27 10:54:01 EST 2002

On Mon, 22 Jul 2002, Edward Farrar wrote:
> Rsync 2.5.5 is producing this error message and a core file when executing the
> command "/usr/local/bin/rsync -av --delete --force /net/OSCM/OS_ATLAS2/CONFIG/.
> /net/OSCM/OS_TITAN1/2.6/CONFIG/. /OS/2.6/CONFIG"
> building file list ... done
> rsync: connection unexpectedly closed (8 bytes read so far)
> rsync error: error in rsync protocol data stream (code 12) at io.c(150)

I looked at the code in flist_find(), and I had the theory that the code
would fail if it found a duplicate name as the last item in the flist.
Sure enough, creating two directories with one duplicate between them
would crash in the same way if that duplicated item is the last one
alphabetically but would succeed otherwise.  The problems stems from the
flist_up() function marching right off the top of the list if the last
item has its basename zeroed out (indicating it is a duplicate).

The easiest fix appears to be to simply trim the high value to ignore
removed items.  Like so:

Index: flist.c
--- flist.c	11 Apr 2002 02:21:41 -0000	1.124
+++ flist.c	27 Jul 2002 17:40:10 -0000
@@ -1151,7 +1151,9 @@
 	int low = 0, high = flist->count - 1;
-	if (flist->count <= 0)
+	while (high >= 0 && !flist->files[high]->basename) high--;
+	if (high < 0)
 		return -1;
 	while (low != high) {

I've tested it and it fixes my crashing testcase, so I'll commit this
to CVS.


More information about the rsync mailing list