[
https://issues.apache.org/jira/browse/COMPRESS-544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17176213#comment-17176213
]
Peter Lee commented on COMPRESS-544:
------------------------------------
Hi [~monktastic]
Seems we didn't check if the bytes we skipped are in the blocks of 512 bytes or
not.
For your testcase :
{code:java}
TarArchiveInputStream tarInput = new TarArchiveInputStream(inputStream);
TarArchiveEntry currentEntry;
while ((currentEntry = tarInput.getNextTarEntry()) != null) {
}
{code}
It would be a little difficult here if you are using _FileInputStream_ for the
variable _inputStream_ - cause the _FileInputStream_ will always return a
positive number even through the EOF is reached(see
[https://stackoverflow.com/questions/11511093/java-inputstream-skip-return-value-near-end-of-file]),
which makes it a little difficult for us to determine how many bytes we are
skipping.
> TarArchiveInputStream#getNextTarEntry does not fail on truncated archive
> ------------------------------------------------------------------------
>
> Key: COMPRESS-544
> URL: https://issues.apache.org/jira/browse/COMPRESS-544
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Affects Versions: 1.20
> Reporter: Aditya Prasad
> Priority: Minor
> Attachments: test.tar, test_truncated.tar
>
>
> The following should throw IOException when given a truncated tar:
> {code:java}
> TarArchiveInputStream tarInput = new TarArchiveInputStream(inputStream);
> TarArchiveEntry currentEntry;
> while ((currentEntry = tarInput.getNextTarEntry()) != null) {
> }
> {code}
> Instead, it completes successfully. I've included a small simple .tar, and a
> truncated version of it. Untaring from the command line fails properly:
> {code:java}
> $ tar -tf test_truncated.tar
> test/
> tar: Truncated tar archive
> tar: Error exit delayed from previous errors.{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)