garydgregory commented on code in PR #455:
URL: https://github.com/apache/commons-compress/pull/455#discussion_r1451603745
##########
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:
Hello @kvr000
Either the option name or the error message is wrong: are we creating a
bound on files in an archive or a count of volumes ("drives")? Or is there
something I am missing?
--
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]