Skip to content

Commit

Permalink
Merge pull request #842 from cushon/zip64
Browse files Browse the repository at this point in the history
Move cenSize check after reading the zip64 eocd
  • Loading branch information
lukehutch committed Apr 4, 2024
2 parents 99a97f1 + 1aab2d4 commit 8a14a6f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,6 @@ private void readCentralDirectory(final NestedJarHandler nestedJarHandler, final
throw new IOException("Multi-disk jarfiles not supported: " + getPath());
}
long cenSize = reader.readUnsignedInt(eocdPos + 12);
if (cenSize > eocdPos) {
throw new IOException(
"Central directory size out of range: " + cenSize + " vs. " + eocdPos + ": " + getPath());
}
long cenOff = reader.readUnsignedInt(eocdPos + 16);
long cenPos = eocdPos - cenSize;

Expand Down Expand Up @@ -536,6 +532,11 @@ private void readCentralDirectory(final NestedJarHandler nestedJarHandler, final
}
}

if (cenSize > eocdPos) {
throw new IOException(
"Central directory size out of range: " + cenSize + " vs. " + eocdPos + ": " + getPath());
}

// Get offset of first local file header
final long locPos = cenPos - cenOff;
if (locPos < 0) {
Expand Down

0 comments on commit 8a14a6f

Please sign in to comment.