[jboss-svn-commits] JBoss Common SVN: r3255 - jzipfile/trunk/src/main/java/org/jboss/jzipfile.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jun 15 13:01:30 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-06-15 13:01:30 -0400 (Mon, 15 Jun 2009)
New Revision: 3255
Modified:
jzipfile/trunk/src/main/java/org/jboss/jzipfile/Zip.java
Log:
Account for tiny empty zip files
Modified: jzipfile/trunk/src/main/java/org/jboss/jzipfile/Zip.java
===================================================================
--- jzipfile/trunk/src/main/java/org/jboss/jzipfile/Zip.java 2009-06-15 15:55:21 UTC (rev 3254)
+++ jzipfile/trunk/src/main/java/org/jboss/jzipfile/Zip.java 2009-06-15 17:01:30 UTC (rev 3255)
@@ -75,7 +75,11 @@
// OK, let's back off incrementally, starting from 64 bytes out and going up by a factor of 4 each time
int spos = 64;
int lim = 64 - 22;
- raf.seek(len - 64);
+ if (len < 64) {
+ raf.seek(0);
+ } else {
+ raf.seek(len - 64);
+ }
while (! catScan(raf, lim)) {
int newSpos = spos << 2;
lim = newSpos - spos;
@@ -83,7 +87,13 @@
if (spos >= 65536) {
throw new ZipException("No directory found");
}
- raf.seek(len - spos);
+ if (spos > len) {
+ // check from the very start of the file
+ spos = 65536;
+ raf.seek(0);
+ } else {
+ raf.seek(len - spos);
+ }
}
}
// OK, the EOD was located. Now read it to find the start of the directory
More information about the jboss-svn-commits
mailing list