Skip to content

Commit

Permalink
Values in ZIP files are unsigned.
Browse files Browse the repository at this point in the history
Bug: 9695860
Change-Id: I5c12dc5f3c70a9fe081adf5bf5b6b4b3a115e7e1
  • Loading branch information
enh-google authored and dkeppler committed Jul 19, 2013
1 parent ad05140 commit 12801c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions luni/src/main/java/java/util/zip/ZipEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,18 @@ public int hashCode() {
}

it.seek(10);
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 commentLength = it.readShort();
nameLength = it.readShort() & 0xffff;
int extraLength = it.readShort() & 0xffff;
int commentLength = it.readShort() & 0xffff;

// This is a 32-bit value in the file, but a 64-bit field in this object.
it.seek(42);
Expand Down
2 changes: 1 addition & 1 deletion luni/src/main/java/java/util/zip/ZipFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public InputStream getInputStream(ZipEntry entry) throws IOException {
// the one coming in the central header.
RAFStream rafstrm = new RAFStream(raf, entry.mLocalHeaderRelOffset + 28);
DataInputStream is = new DataInputStream(rafstrm);
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:
Expand Down

0 comments on commit 12801c7

Please sign in to comment.