Hi,

I sent a patch for a problem in usage of zlib a day before yesterday.
But It was wrong, it causes another problems.  Sorry.

I attached new patch.  Please check.

--yasuoka

On Fri, 27 Jun 2003 20:44:11 +0900 (JST)
Yasuoka Masahiko <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I think I found a bug in usage of zlib.  rsync 2.5.6 with -z fails
> like bellow.
> 
>   % cp install-disk2.iso /var/tmp/install-disk2.iso
>   install-disk2.iso    100% |*****************************|   316 MB    00:56    
>   % rsync -vIz install-disk2.iso 127.0.0.1:/var/tmp/install-disk2.iso
>   install-disk2.iso
>   deflate on token returned 0 (16384 bytes left)
>   rsync error: error in rsync protocol data stream (code 12) at token.c(288)
> 
> "install-disk2.iso" is a CD-ROM image of "Turbo Linux Installer" and
> this CD-ROM includes many gzip/bzip2 compressed datas(RPMs).
> 
> Let's looked at token.c.
> 
>     280      tx_strm.next_in = (Bytef *) map_ptr(buf, offset, toklen);
>     281      tx_strm.avail_in = toklen;
>     282      tx_strm.next_out = (Bytef *) obuf;
>     283      tx_strm.avail_out = MAX_DATA_COUNT;
>     284      r = deflate(&tx_strm, Z_INSERT_ONLY);
>     285      if (r != Z_OK || tx_strm.avail_in != 0) {
>     286              rprintf(FERROR, "deflate on token returned %d (%d bytes 
> left)\n",
>     287                      r, tx_strm.avail_in);
>     288              exit_cleanup(RERR_STREAMIO);
>     289      }
> 
> MAX_DATA_COUNT is 16383 and toklen may be 16384.  So, when deflate()'s
> outputs data length is bigger than input, then above code will fail.
> Normally output data length is smaller than input, but it is not true
> to already compressed data.
Index: token.c
===================================================================
RCS file: /vol/cvs/datacube/src/auxcmd/rsync/token.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 token.c
--- token.c     8 Apr 2002 08:35:30 -0000       1.1.1.1
+++ token.c     29 Jun 2003 01:18:15 -0000
@@ -279,10 +279,17 @@ send_deflated_token(int f, int token,
                   history and hash table */
                tx_strm.next_in = (Bytef *) map_ptr(buf, offset, toklen);
                tx_strm.avail_in = toklen;
-               tx_strm.next_out = (Bytef *) obuf;
-               tx_strm.avail_out = MAX_DATA_COUNT;
-               r = deflate(&tx_strm, Z_INSERT_ONLY);
-               if (r != Z_OK || tx_strm.avail_in != 0) {
+               do {
+                       tx_strm.next_out = (Bytef *) obuf;
+                       tx_strm.avail_out = MAX_DATA_COUNT;
+                       r = deflate(&tx_strm, Z_INSERT_ONLY);
+                       if (r != Z_OK) {
+                               rprintf(FERROR, "deflate on token returned %d "
+                                   "(%d bytes left)\n", r, tx_strm.avail_in);
+                               exit_cleanup(RERR_STREAMIO);
+                       }
+               } while (tx_strm.avail_out == 0 && tx_strm.avail_in > 0);
+               if (tx_strm.avail_in != 0) {
                        rprintf(FERROR, "deflate on token returned %d (%d bytes 
left)\n",
                                r, tx_strm.avail_in);
                        exit_cleanup(RERR_STREAMIO);
-- 
To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html

Reply via email to