[
https://issues.apache.org/jira/browse/COMPRESS-585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17392876#comment-17392876
]
Peter Lee commented on COMPRESS-585:
------------------------------------
_> The cause is that {{ZipFile.readCentralDirectoryEntry()}} calls
{{IOUtils.readRange()}} and assumes if it returns less than the length it asked
for that the EOF is reached, however this is not how that method works: it
returns max COPY_BUF_SIZE bytes (8024), even if EOF has not been reached._
Can this problem be reproduced?
The _COPY_BUF_SIZE_ is just the limit of buffer' size. With _rewind_ called,
the buffer can be reused to copy more than _COPY_BUF_SIZE_ bytes of data.
> ZipFile fails to read a zipfile with a comment or extra data longer than 8024
> bytes
> -----------------------------------------------------------------------------------
>
> Key: COMPRESS-585
> URL: https://issues.apache.org/jira/browse/COMPRESS-585
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Affects Versions: 1.21
> Reporter: Matthijs Laan
> Priority: Minor
> Attachments: COMPRESS-585-test.patch
>
>
> See the attached patch for a unit test demonstrating the issue with a long
> comment.
> The cause is that {{ZipFile.readCentralDirectoryEntry()}} calls
> {{IOUtils.readRange()}} and assumes if it returns less than the length it
> asked for that the EOF is reached, however this is not how that method works:
> it returns max COPY_BUF_SIZE bytes (8024), even if EOF has not been reached.
> Besides comments and extra data (in the central directory or local file
> header) longer than 8024 bytes the only other place {{readRange()}} is called
> is reading filenames, but that seems like a remote edge case and an EOF
> exception is fine.
> The IOUtils.readRange() JavaDoc does not specify how it communicates EOF.
> With a blocking channel this would be when it returns a zero length array. It
> could throw an exception when {{Channel.read()}} returns 0 bytes, because
> that only happens on non-blocking channels.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)