From: Wayne Davison Date: Mon, 21 Nov 2011 17:13:11 +0000 (-0800) Subject: Fix --compress data-duplication bug. X-Git-Tag: v3.1.0pre1~64 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=cbdff74b44b25ce713739b9c1fb4db67610c675e;p=rsync.git Fix --compress data-duplication bug. --- diff --git a/rsync.h b/rsync.h index 57e3d79d..0c958c6c 100644 --- a/rsync.h +++ b/rsync.h @@ -103,7 +103,7 @@ /* 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 75d2b17b..381d5c1f 100644 --- 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; }