rsync error: error in rsync protocol data stream (code 12) at io.c(463)

Dag Wieers dag at wieers.com
Sun Sep 14 07:24:10 EST 2003


On Sat, 13 Sep 2003, Dag Wieers wrote:

> I'm having a problem rsyncing one file (since I signed it). It seems that 
> the content of a file is able to cause problems in the protocol.
> 
> 	building file list ... 
> 	28820 files to consider
> 	apt/packages/avifile/
> 	apt/packages/avifile/avifile-0.7.34-1.dag.rh90.i386.rpm
> 	rsync: error writing 4 unbuffered bytes - exiting: Broken pipe
> 	rsync error: error in rsync protocol data stream (code 12) at io.c(463)
> 
> I'm using rsync-2.5.5-4 (the rsync shipped with RH9). The first time rsync 
> halted (indefinitely), every other run gives the above error.

Using rsync-2.5.6 I get the exact same error:

	building file list ... 
	28844 files to consider
	apt/packages/
	apt/packages/avifile/
	apt/packages/avifile/avifile-0.7.34-1.dag.rh90.i386.rpm
	rsync: writefd_unbuffered failed to write 4 bytes: phase "unknown": Broken pipe
	rsync error: error in rsync protocol data stream (code 12) at io.c(515)

I'm now going to test with an unpatched rsync, although looking at the Red 
Hat patches I don't see anything that could cause this.


PS: Is there a reason why the Red Hat patches are not applied to the rsync 
sourcecode ? I've attached them for inspection.

--   dag wieers,  dag at wieers.com,  http://dag.wieers.com/   --
[Any errors in spelling, tact or fact are transmission errors]
-------------- next part --------------
--- io.c.orig	2003-09-13 22:36:40.000000000 +0200
+++ io.c	2003-09-13 22:39:13.000000000 +0200
@@ -509,7 +509,7 @@
 				 * across the stream */
 				io_multiplexing_close();
 				rprintf(FERROR, RSYNC_NAME
-					": writefd_unbuffered failed to write %ld bytes: phase \"%s\": %s\n",
+					": writefd_unbuffered failed to write %lu bytes: phase \"%s\": %s\n",
 					(long) len, io_write_phase, 
 					strerror(errno));
 				exit_cleanup(RERR_STREAMIO);
@@ -605,7 +605,7 @@
 	}
 
 	while (len) {
-		int n = MIN((int) len, IO_BUFFER_SIZE-io_buffer_count);
+		int n = MIN((ssize_t) len, IO_BUFFER_SIZE-io_buffer_count);
 		if (n > 0) {
 			memcpy(io_buffer+io_buffer_count, buf, n);
 			buf += n;
--- match.c.orig	2003-09-13 22:39:22.000000000 +0200
+++ match.c	2003-09-13 22:42:59.000000000 +0200
@@ -153,12 +153,12 @@
 	last_i = -1;
 
 	if (verbose > 2)
-		rprintf(FINFO,"hash search b=%ld len=%.0f\n",
+		rprintf(FINFO,"hash search b=%lu len=%.0f\n",
 			(long) s->n, (double)len);
 
 	/* cast is to make s->n signed; it should always be reasonably
 	 * small */
-	k = MIN(len, (OFF_T) s->n);
+	k = MIN(len, (ssize_t) s->n);
 	
 	map = (schar *)map_ptr(buf,0,k);
 	
@@ -173,7 +173,7 @@
 	end = len + 1 - s->sums[s->count-1].len;
 	
 	if (verbose > 3)
-		rprintf(FINFO, "hash search s->n=%ld len=%.0f count=%ld\n",
+		rprintf(FINFO, "hash search s->n=%lu len=%.0f count=%lu\n",
 			(long) s->n, (double) len, (long) s->count);
 	
 	do {
@@ -190,13 +190,13 @@
 
 		sum = (s1 & 0xffff) | (s2 << 16);
 		tag_hits++;
-		for (; j < (int) s->count && targets[j].t == t; j++) {
+		for (; j < (ssize_t) s->count && targets[j].t == t; j++) {
 			int l, i = targets[j].i;
 			
 			if (sum != s->sums[i].sum1) continue;
 			
 			/* also make sure the two blocks are the same length */
-			l = MIN(s->n,len-offset);
+			l = MIN((ssize_t) s->n,len-offset);
 			if (l != s->sums[i].len) continue;			
 
 			if (verbose > 3)
@@ -216,7 +216,7 @@
 
 			/* we've found a match, but now check to see
                            if last_i can hint at a better match */
-			for (j++; j < (int) s->count && targets[j].t == t; j++) {
+			for (j++; j < (ssize_t) s->count && targets[j].t == t; j++) {
 				int i2 = targets[j].i;
 				if (i2 == last_i + 1) {
 					if (sum != s->sums[i2].sum1) break;
@@ -232,7 +232,7 @@
 			
 			matched(f,s,buf,offset,i);
 			offset += s->sums[i].len - 1;
-			k = MIN((len-offset), s->n);
+			k = MIN((len-offset), (ssize_t) s->n);
 			map = (schar *)map_ptr(buf,offset,k);
 			sum = get_checksum1((char *)map, k);
 			s1 = sum & 0xFFFF;
@@ -262,7 +262,7 @@
 		   running match, the checksum update and the
 		   literal send. */
 		if (offset > last_match &&
-		    offset-last_match >= CHUNK_SIZE+s->n && 
+		    offset-last_match >= (ssize_t) CHUNK_SIZE+s->n && 
 		    (end-offset > CHUNK_SIZE)) {
 			matched(f,s,buf,offset - s->n, -2);
 		}
--- sender.c.orig	2003-09-13 22:43:11.000000000 +0200
+++ sender.c	2003-09-13 22:43:42.000000000 +0200
@@ -55,7 +55,7 @@
 	s->sums = NULL;
 
 	if (verbose > 3)
-		rprintf(FINFO,"count=%ld n=%ld rem=%ld\n",
+		rprintf(FINFO,"count=%lu n=%lu rem=%lu\n",
 			(long) s->count, (long) s->n, (long) s->remainder);
 
 	if (s->count == 0) 
-------------- next part --------------
--- rsync-2.4.2/options.c.maxdel	Thu Mar 30 09:23:02 2000
+++ rsync-2.4.2/options.c	Tue Apr  4 10:59:34 2000
@@ -64,7 +64,10 @@
 int delete_after=0;
 int only_existing=0;
 int opt_ignore_existing=0;
-int max_delete=0;
+#if !defined(MAX_DELETE)       /* XXX preserve legacy Red Hat behavior */
+#define        MAX_DELETE      1000000000
+#endif
+int max_delete = MAX_DELETE;
 int ignore_errors=0;
 #ifdef _WIN32
 int modify_window=2;
@@ -645,7 +648,7 @@
 		args[ac++] = bsize;
 	}    
 
-	if (max_delete && am_sender) {
+	if (max_delete && (max_delete != MAX_DELETE) && am_sender) {
 		snprintf(mdelete,sizeof(mdelete),"--max-delete=%d",max_delete);
 		args[ac++] = mdelete;
 	}    
-------------- next part --------------
--- rsync-2.4.6/main.c.foo	Fri Aug 17 11:46:03 2001
+++ rsync-2.4.6/main.c	Fri Aug 17 11:45:37 2001
@@ -534,6 +534,7 @@
 {
 	char *p, *p2;
 
+	if (!s || !*s) return NULL;
 	p = strchr(s,':');
 	if (!p) return NULL;
 	


More information about the rsync mailing list