8272746: ZipFile can't open big file (NegativeArraySizeException)

Reviewed-by: lancea
This commit is contained in:
Masanori Yano 2022-01-18 18:20:57 +00:00 committed by Lance Andersen
parent b734dc86ee
commit 848b16a3f9
2 changed files with 92 additions and 0 deletions

View file

@ -1497,6 +1497,9 @@ public class ZipFile implements ZipConstants, Closeable {
zerror("invalid END header (bad central directory offset)");
}
// read in the CEN and END
if (end.cenlen + ENDHDR >= Integer.MAX_VALUE) {
zerror("invalid END header (central directory size too large)");
}
cen = this.cen = new byte[(int)(end.cenlen + ENDHDR)];
if (readFullyAt(cen, 0, cen.length, cenpos) != end.cenlen + ENDHDR) {
zerror("read CEN tables failed");