You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2009/10/08 14:26:42 UTC
svn commit: r823144 -
/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/zip/ZipFile.java
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;