On 13 February 2015 at 19:12, <bode...@apache.org> wrote: > Author: bodewig > Date: Fri Feb 13 19:12:09 2015 > New Revision: 1659649 > > URL: http://svn.apache.org/r1659649 > Log: > python tarfile library seems to create embedded NULs, COMPRESS-301, unit test > to follow
-1 (for the moment) I don't think we have proof that any tar libraries create such malformed tar files. It seems wrong to allow this. > Modified: > > commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java > > commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java > commons/proper/compress/trunk/src/test/resources/COMPRESS-178.tar > > Modified: > commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java > URL: > http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java?rev=1659649&r1=1659648&r2=1659649&view=diff > ============================================================================== > --- > commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java > (original) > +++ > commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java > Fri Feb 13 19:12:09 2015 > @@ -132,6 +132,11 @@ public class TarUtils { > > for ( ;start < end; start++) { > final byte currentByte = buffer[start]; > + if (currentByte == 0) { > + // some archivers don't pad the whole field but just insert > a NUL > + // COMPRESS-301 > + break; > + } > // CheckStyle:MagicNumber OFF > if (currentByte < '0' || currentByte > '7'){ > throw new IllegalArgumentException( > > Modified: > commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java > URL: > http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java?rev=1659649&r1=1659648&r2=1659649&view=diff > ============================================================================== > --- > commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java > (original) > +++ > commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/tar/TarUtilsTest.java > Fri Feb 13 19:12:09 2015 > @@ -95,12 +95,6 @@ public class TarUtilsTest extends TestCa > fail("Expected IllegalArgumentException - embedded space"); > } catch (IllegalArgumentException expected) { > } > - buffer = " 0\00007 ".getBytes(CharsetNames.UTF_8); // Invalid - > embedded NUL > - try { > - TarUtils.parseOctal(buffer,0, buffer.length); > - fail("Expected IllegalArgumentException - embedded NUL"); > - } catch (IllegalArgumentException expected) { > - } > } > > private void checkRoundTripOctal(final long value, final int bufsize) { > > Modified: commons/proper/compress/trunk/src/test/resources/COMPRESS-178.tar > URL: > http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/resources/COMPRESS-178.tar?rev=1659649&r1=1659648&r2=1659649&view=diff > ============================================================================== > Binary files - no diff available. > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org