You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ilja Pavkovic (JIRA)" <ji...@apache.org> on 2013/12/10 13:41:07 UTC
[jira] [Updated] (COMPRESS-249) TarArchiveInputStream does not
properly read from underlying InputStream
[ https://issues.apache.org/jira/browse/COMPRESS-249?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ilja Pavkovic updated COMPRESS-249:
-----------------------------------
Description:
TarArchiveInputStream reads header with its protected function readRecord(). This code improperly assumes that is.read(buf) always fills the whole buffer. This assumption is wrong. A proper implementation needs to call read multiple times until all bytes are read:
{code:title=TarArchiveInputStream.java|borderStyle=solid}
protected byte[] readRecord() throws IOException {
byte[] record = new byte[recordSize];
// start change
// int readNow = is.read(buf);
int readNow = 0;
while(readNow < recordSize){
int bytesRead = is.read(record,0, recordSize - readNow);
if(bytesRead == -1) {
break;
}
readNow += bytesRead;
}
// end change
count(readNow);
if (readNow != recordSize) {
return null;
}
return record;
}
{code}
was:
TarArchiveInputStream reads header with its protected function readRecord(). This code improperly assumes that is.read(buf) always fills the whole buffer. This assumption is wrong. A proper implementation needs to call read multiple times until all bytes are read:
{code:title=TarArchiveInputStream.java|borderStyle=solid}
protected byte[] readRecord() throws IOException {
byte[] record = new byte[recordSize];
// start change
// int readNow = is.read(buf);
int readNow = 0;
while(readNow <= recordSize){
int bytesRead = is.read(record,0, recordSize - readNow);
if(bytesRead == -1) {
break;
}
readNow += bytesRead;
}
// end change
count(readNow);
if (readNow != recordSize) {
return null;
}
return record;
}
{code}
> TarArchiveInputStream does not properly read from underlying InputStream
> ------------------------------------------------------------------------
>
> Key: COMPRESS-249
> URL: https://issues.apache.org/jira/browse/COMPRESS-249
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Affects Versions: 1.6
> Reporter: Ilja Pavkovic
> Priority: Critical
> Fix For: 1.7
>
>
> TarArchiveInputStream reads header with its protected function readRecord(). This code improperly assumes that is.read(buf) always fills the whole buffer. This assumption is wrong. A proper implementation needs to call read multiple times until all bytes are read:
> {code:title=TarArchiveInputStream.java|borderStyle=solid}
> protected byte[] readRecord() throws IOException {
> byte[] record = new byte[recordSize];
> // start change
> // int readNow = is.read(buf);
> int readNow = 0;
> while(readNow < recordSize){
> int bytesRead = is.read(record,0, recordSize - readNow);
> if(bytesRead == -1) {
> break;
> }
> readNow += bytesRead;
> }
> // end change
> count(readNow);
> if (readNow != recordSize) {
> return null;
> }
> return record;
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.1.4#6159)