Author: bodewig
Date: Wed Mar 17 15:47:57 2010
New Revision: 924336
URL: http://svn.apache.org/viewvc?rev=924336&view=rev
Log:
actually read content of data descriptor
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Modified:
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
URL:
http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java?rev=924336&r1=924335&r2=924336&view=diff
==============================================================================
---
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
(original)
+++
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
Wed Mar 17 15:47:57 2010
@@ -372,15 +372,7 @@ public class ZipArchiveInputStream exten
}
if (hasDataDescriptor) {
- byte[] sig = new byte[WORD];
- readFully(sig);
- if (ZipLong.DD_SIG.equals(new ZipLong(sig))) {
- readFully(new byte[3 * WORD]);
- } else {
- // data descriptor without signature, we've already
- // read the CRC
- readFully(new byte[2 * WORD]);
- }
+ readDataDescriptor();
}
inf.reset();
@@ -410,4 +402,21 @@ public class ZipArchiveInputStream exten
count(x);
}
}
+
+ private void readDataDescriptor() throws IOException {
+ byte[] b = new byte[WORD];
+ readFully(b);
+ ZipLong val = new ZipLong(b);
+ if (ZipLong.DD_SIG.equals(val)) {
+ // data descriptor with signature, skip sig
+ readFully(b);
+ val = new ZipLong(b);
+ }
+ current.setCrc(val.getValue());
+ readFully(b);
+ current.setCompressedSize(new ZipLong(b).getValue());
+ readFully(b);
+ current.setSize(new ZipLong(b).getValue());
+ }
+
}