Hi,

It's been a while, so I hope I remember the protocols :-)

2010-01-11  Jeroen Frijters  <jer...@frijters.net>

        * java/util/zip/Inflater. java (inflate(byte[],int,int)): Fix for 
#41696.

Besides the fix for the bug mentioned, this also fixes the checksum check, 
which previously wouldn't occur if len was exactly sufficient to contain all 
the remaining data.

Regards,
Jeroen

Index: Inflater.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/zip/Inflater.java,v
retrieving revision 1.11
diff -u -r1.11 Inflater.java
--- Inflater.java       12 Mar 2008 23:39:51 -0000      1.11
+++ Inflater.java       11 Jan 2010 14:07:24 -0000
@@ -311,37 +311,29 @@
    */
   public int inflate (byte[] buf, int off, int len) throws DataFormatException
   {
-    /* Special case: len may be zero */
-    if (len == 0)
-      return 0;
     /* Check for correct buff, off, len triple */
     if (0 > off || off > off + len || off + len > buf.length)
       throw new ArrayIndexOutOfBoundsException();
     int count = 0;
-    int more;
-    do
+    for (;;)
       {
-       if (mode != DECODE_CHKSUM)
-         {
-           /* Don't give away any output, if we are waiting for the
-            * checksum in the input stream.
-            *
-            * With this trick we have always:
-            *   needsInput() and not finished() 
-            *   implies more output can be produced.  
-            */
-           more = outputWindow.copyOutput(buf, off, len);
-           adler.update(buf, off, more);
-           off += more;
-           count += more;
-           totalOut += more;
-           len -= more;
-           if (len == 0)
-             return count;
-         }
+        if (outputWindow.getAvailable() == 0)
+          {
+            if (!decode())
+              break;
+          }
+        else if (len > 0)
+          {
+            int more = outputWindow.copyOutput(buf, off, len);
+            adler.update(buf, off, more);
+            off += more;
+            count += more;
+            totalOut += more;
+            len -= more;
+          }
+        else
+          break;
       }
-    while (decode() || (outputWindow.getAvailable() > 0
-                       && mode != DECODE_CHKSUM));
     return count;
   }
 


Reply via email to