harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r823144 - /harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
Date Thu, 08 Oct 2009 12:26:42 GMT
Author: tellison
Date: Thu Oct  8 12:26:42 2009
New Revision: 823144

URL: http://svn.apache.org/viewvc?rev=823144&view=rev
Log:
Avoid potential long arithmetic overflow, and account for file reads possibly returning zero
bytes read.

Modified:
    harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java?rev=823144&r1=823143&r2=823144&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
Thu Oct  8 12:26:42 2009
@@ -382,11 +382,11 @@
 
         @Override
         public int read() throws IOException {
-            if (read(singleByteBuf, 0, 1) == 1) {
-                return singleByteBuf[0] & 0XFF;
-            } else {
-                return -1;
+            int count = read(singleByteBuf, 0, 1); 
+            if (count == 1) {
+                return singleByteBuf[0] & 0xFF;
             }
+            return count;
         }
 
         @Override
@@ -399,16 +399,14 @@
                 int count = mSharedRaf.read(b, off, len);
                 if (count > 0) {
                     mOffset += count;
-                    return count;
-                } else {
-                    return -1;
                 }
+                return count;
             }
         }
 
         @Override
         public long skip(long n) throws IOException {
-            if (mOffset + n > mLength) {
+            if (n > mLength - mOffset) {
                 n = mLength - mOffset;
             }
             mOffset += n;



Mime
View raw message