Bug#739655: libcommons-compress-java: TarArchiveInputStream copes poorly with short reads from underlying stream

Jonathan Nieder jrnieder at gmail.com
Fri Feb 21 00:00:41 UTC 2014

Package: libcommons-compress-java
Version: 1.6-1
Tags: upstream patch fixed-upstream
Severity: important
Justification: regression
Control: forwarded -1 https://issues.apache.org/jira/browse/COMPRESS-245


>From upstream issue COMPRESS-245:

	The attached archive decompressed with 1.6 only extracts part
	of the archive. This does not happen with version 1.5

	FileInputStream fin = new FileInputStream("exampletar.tar.gz");
	GZIPInputStream gin = new GZIPInputStream(fin);
	TarArchiveInputStream tin = new TarArchiveInputStream(gin);
	TarArchiveEntry entry;
        while ((entry = tin.getNextTarEntry()) != null) {

Fixed by r1548380 "COMPRESS-245 TarArchiveInputStream might fail to
read a stream if a single call to read() returns less than a full

	--- src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java  (revision 1548379)
	+++ src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java  (revision 1548380)
	@@ -385,7 +385,7 @@
	         byte[] record = new byte[recordSize];
	-        int readNow = is.read(record);
	+        int readNow = IOUtils.readFully(is, record);
	         if (readNow != recordSize) {
	             return null;

r1548388 "testcase for COMPRESS-245 provided by Andreas Aronsson"
has a test.

More information about the pkg-java-maintainers mailing list