summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-07-03 16:23:31 -0700
committerThe Android Automerger <android-build@android.com>2013-07-09 16:33:01 -0700
commit339f18ff18ea0c13fae1d6750ffe8eaf847e62e9 (patch)
tree5f5c735a26be664c3ce80ccd4677609b59d93725
parent554f25600a5335131f085eca41820614f3a29cf9 (diff)
downloadlibcore-339f18ff18ea0c13fae1d6750ffe8eaf847e62e9.zip
libcore-339f18ff18ea0c13fae1d6750ffe8eaf847e62e9.tar.gz
libcore-339f18ff18ea0c13fae1d6750ffe8eaf847e62e9.tar.bz2
Values in ZIP files are unsigned.
Bug: 9695860 (cherry picked from commit 9edf43dfcc35c761d97eb9156ac4254152ddbc55) Change-Id: Ic14eac58fdcfc343a9e23df8c26ba0dd24c9e189
-rw-r--r--luni/src/main/java/java/util/zip/ZipEntry.java14
-rw-r--r--luni/src/main/java/java/util/zip/ZipFile.java4
2 files changed, 9 insertions, 9 deletions
diff --git a/luni/src/main/java/java/util/zip/ZipEntry.java b/luni/src/main/java/java/util/zip/ZipEntry.java
index 91485e7..5becf97 100644
--- a/luni/src/main/java/java/util/zip/ZipEntry.java
+++ b/luni/src/main/java/java/util/zip/ZipEntry.java
@@ -358,24 +358,24 @@ public class ZipEntry implements ZipConstants, Cloneable {
}
it.seek(8);
- int gpbf = it.readShort();
+ int gpbf = it.readShort() & 0xffff;
if ((gpbf & ZipFile.GPBF_UNSUPPORTED_MASK) != 0) {
throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
}
- compressionMethod = it.readShort();
- time = it.readShort();
- modDate = it.readShort();
+ compressionMethod = it.readShort() & 0xffff;
+ time = it.readShort() & 0xffff;
+ modDate = it.readShort() & 0xffff;
// These are 32-bit values in the file, but 64-bit fields in this object.
crc = ((long) it.readInt()) & 0xffffffffL;
compressedSize = ((long) it.readInt()) & 0xffffffffL;
size = ((long) it.readInt()) & 0xffffffffL;
- nameLength = it.readShort();
- int extraLength = it.readShort();
- int commentByteCount = it.readShort();
+ nameLength = it.readShort() & 0xffff;
+ int extraLength = it.readShort() & 0xffff;
+ int commentByteCount = it.readShort() & 0xffff;
// This is a 32-bit value in the file, but a 64-bit field in this object.
it.seek(42);
diff --git a/luni/src/main/java/java/util/zip/ZipFile.java b/luni/src/main/java/java/util/zip/ZipFile.java
index 9b48b53..26ca14e 100644
--- a/luni/src/main/java/java/util/zip/ZipFile.java
+++ b/luni/src/main/java/java/util/zip/ZipFile.java
@@ -263,7 +263,7 @@ public class ZipFile implements ZipConstants {
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT
RAFStream rafStream= new RAFStream(localRaf, entry.localHeaderRelOffset + 6);
DataInputStream is = new DataInputStream(rafStream);
- int gpbf = Short.reverseBytes(is.readShort());
+ int gpbf = Short.reverseBytes(is.readShort()) & 0xffff;
if ((gpbf & ZipFile.GPBF_UNSUPPORTED_MASK) != 0) {
throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
}
@@ -271,7 +271,7 @@ public class ZipFile implements ZipConstants {
// At position 28 we find the length of the extra data. In some cases
// this length differs from the one coming in the central header.
is.skipBytes(20);
- int localExtraLenOrWhatever = Short.reverseBytes(is.readShort());
+ int localExtraLenOrWhatever = Short.reverseBytes(is.readShort()) & 0xffff;
is.close();
// Skip the name and this "extra" data or whatever it is: