commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (COMPRESS-270) TarArchiveInputStream fails to read PAX header from InputStream
Date Fri, 28 Mar 2014 16:30:19 GMT

     [ https://issues.apache.org/jira/browse/COMPRESS-270?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Stefan Bodewig resolved COMPRESS-270.
-------------------------------------

    Resolution: Fixed

found two more cases inside the snappy and the ar package

> TarArchiveInputStream fails to read PAX header from InputStream
> ---------------------------------------------------------------
>
>                 Key: COMPRESS-270
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-270
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Archivers
>    Affects Versions: 1.8
>            Reporter: Patrik Burkhalter
>              Labels: tar
>             Fix For: 1.9
>
>
> We have a scenario with a "slow" {{InputStream}} and are facing {{IOExceptions}} with
{{TarArchiveEntry#getNextTarEntry()}}.
> If the {{InputStream}} does not deliver fast enough, {{TarArchiveEntry#parsePaxHeaders(InputStream
i)}} fails at this location:
> {code:title=TarArchiveInputStream.java|borderStyle=solid}
> // Get rest of entry
> byte[] rest = new byte[len - read];
> int got = i.read(rest);
> if (got != len - read){
> 	throw new IOException("Failed to read "
> 		+ "Paxheader. Expected "
> 		+ (len - read)
> 		+ " bytes, read "
> 		+ got);
> }
> {code}
> We would suggest to change the code to something like this:
> {code:title=TarArchiveInputStream.java|borderStyle=solid}
> // Get rest of entry
> byte[] rest = new byte[len - read];
> int got = 0;
> while((ch = i.read()) != -1) {
> 	rest[got] = (byte) ch;
> 	got++;
> 	if(got == len - read) {
> 		break;
> 	}
> }
> if (got != len - read){
> 	throw new IOException("Failed to read "
> 		+ "Paxheader. Expected "
> 		+ (len - read)
> 		+ " bytes, read "
> 		+ got);
> }
> {code}
> This would make sure, that it gets all bytes of the PAX header value.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message