Browse Source

Deal with InputStreams that don't return the full PAX header in one

read()

This used to be https://issues.apache.org/jira/browse/COMPRESS-270
master
Stefan Bodewig 11 years ago
parent
commit
8819ee167b
2 changed files with 12 additions and 5 deletions
  1. +3
    -0
      WHATSNEW
  2. +9
    -5
      src/main/org/apache/tools/tar/TarInputStream.java

+ 3
- 0
WHATSNEW View File

@@ -11,6 +11,9 @@ Fixed bugs:
fields.
Bugzilla Report 56641

* TarArchiveInputStream could throw IOException when reading PAX
headers from a "slow" InputStream.

Other changes:
--------------



+ 9
- 5
src/main/org/apache/tools/tar/TarInputStream.java View File

@@ -431,18 +431,22 @@ public class TarInputStream extends FilterInputStream {
if (ch == '='){ // end of keyword
String keyword = coll.toString("UTF-8");
// Get rest of entry
byte[] rest = new byte[len - read];
int got = i.read(rest);
if (got != len - read){
final int restLen = len - read;
byte[] rest = new byte[restLen];
int got = 0;
while (got < restLen && (ch = i.read()) != -1) {
rest[got++] = (byte) ch;
}
if (got != restLen) {
throw new IOException("Failed to read "
+ "Paxheader. Expected "
+ (len - read)
+ restLen
+ " bytes, read "
+ got);
}
// Drop trailing NL
String value = new String(rest, 0,
len - read - 1, "UTF-8");
restLen - 1, "UTF-8");
headers.put(keyword, value);
break;
}


Loading…
Cancel
Save