Fix --compress data-duplication bug.
authorWayne Davison <wayned@samba.org>
Mon, 21 Nov 2011 17:13:11 +0000 (09:13 -0800)
committerWayne Davison <wayned@samba.org>
Mon, 21 Nov 2011 17:17:17 +0000 (09:17 -0800)
rsync.h
token.c

diff --git a/rsync.h b/rsync.h
index 57e3d79d046f6860a22435008cb2178a4da9a075..0c958c6c8f4b16ce2939eb53c7eb4fe4ccdbc7c4 100644 (file)
--- a/rsync.h
+++ b/rsync.h
 /* This is used when working on a new protocol version in CVS, and should
  * be a new non-zero value for each CVS change that affects the protocol.
  * It must ALWAYS be 0 when the protocol goes final (and NEVER before)! */
-#define SUBPROTOCOL_VERSION 13
+#define SUBPROTOCOL_VERSION 14
 
 /* We refuse to interoperate with versions that are not in this range.
  * Note that we assume we'll work with later versions: the onus is on
diff --git a/token.c b/token.c
index 75d2b17b48fffc432f70e86da279861a6e337283..381d5c1f99e4fcf6824441792d1847a179923d92 100644 (file)
--- a/token.c
+++ b/token.c
@@ -24,6 +24,7 @@
 #include "zlib/zlib.h"
 
 extern int do_compression;
+extern int protocol_version;
 extern int module_id;
 extern int def_compress_level;
 extern char *skip_compress;
@@ -411,6 +412,8 @@ send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
                        toklen -= n1;
                        tx_strm.next_in = (Bytef *)map_ptr(buf, offset, n1);
                        tx_strm.avail_in = n1;
+                       if (protocol_version >= 31) /* Newer protocols avoid a data-duplicating bug */
+                               offset += n1;
                        tx_strm.next_out = (Bytef *) obuf;
                        tx_strm.avail_out = AVAIL_OUT_SIZE(CHUNK_SIZE);
                        r = deflate(&tx_strm, Z_INSERT_ONLY);
@@ -593,6 +596,8 @@ static void see_deflate_token(char *buf, int32 len)
                        } else {
                                rx_strm.next_in = (Bytef *)buf;
                                rx_strm.avail_in = blklen;
+                               if (protocol_version >= 31) /* Newer protocols avoid a data-duplicating bug */
+                                       buf += blklen;
                                len -= blklen;
                                blklen = 0;
                        }