kvr000 commented on code in PR #455:
URL: https://github.com/apache/commons-compress/pull/455#discussion_r1451640900
##########
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:
##########
@@ -684,6 +715,53 @@ public ZipFile(final String name, final String encoding)
throws IOException {
this(new File(name).toPath(), encoding, true);
}
+ private static SeekableByteChannel openZipArchive(Path path,
ZipOpenOptions options) throws IOException {
+ FileChannel channel = FileChannel.open(path, StandardOpenOption.READ);
+ List<FileChannel> channels = new ArrayList<>();
+ try {
+ boolean is64 = positionAtEndOfCentralDirectoryRecord(channel);
+ long numberOfFiles;
+ if (is64) {
+ channel.position(channel.position() + ZipConstants.WORD +
ZipConstants.WORD + ZipConstants.DWORD);
+ ByteBuffer buf = ByteBuffer.allocate(ZipConstants.WORD);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+ IOUtils.readFully(channel, buf);
+ buf.flip();
+ numberOfFiles = buf.getInt() & 0xffffffffL;
+ } else {
+ channel.position(channel.position() + ZipConstants.WORD);
+ ByteBuffer buf = ByteBuffer.allocate(ZipConstants.SHORT);
+ buf.order(ByteOrder.LITTLE_ENDIAN);
+ IOUtils.readFully(channel, buf);
+ buf.flip();
+ numberOfFiles = (buf.getShort() & 0xffff) + 1;
+ }
+ if (numberOfFiles > Math.min(options.maxNumberOfDisks(),
Integer.MAX_VALUE)) {
+ throw new IOException("Too many files in zip archive, max=" +
Review Comment:
Correct, the message was misleading. I corrected to `Too many disks...` .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]