Browse Source

be more lenient when parsing tar headers

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1570454 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 11 years ago
parent
commit
38f4bc677b
2 changed files with 14 additions and 11 deletions
  1. +4
    -0
      WHATSNEW
  2. +10
    -11
      src/main/org/apache/tools/tar/TarUtils.java

+ 4
- 0
WHATSNEW View File

@@ -84,6 +84,10 @@ Fixed bugs:
extend Javadoc
Bugzilla Report 56047

* TarInputStream will now read archives created by tar
implementations that encode big numbers by not adding a trailing
NUL.

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



+ 10
- 11
src/main/org/apache/tools/tar/TarUtils.java View File

@@ -121,19 +121,18 @@ public class TarUtils {
}
}

// Must have trailing NUL or space
byte trailer;
trailer = buffer[end-1];
if (trailer == 0 || trailer == ' '){
// Trim all trailing NULs and spaces.
// The ustar and POSIX tar specs require a trailing NUL or
// space but some implementations use the extra digit for big
// sizes/uids/gids ...
byte trailer = buffer[end - 1];
while (start < end && (trailer == 0 || trailer == ' ')) {
end--;
} else {
throw new IllegalArgumentException(
exceptionMessage(buffer, offset, length, end-1, trailer));
trailer = buffer[end - 1];
}
// May have additional NUL or space
trailer = buffer[end-1];
if (trailer == 0 || trailer == ' '){
end--;
if (start == end) {
throw new IllegalArgumentException(
exceptionMessage(buffer, offset, length, start, trailer));
}

for ( ;start < end; start++) {


Loading…
Cancel
Save