You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by bo...@apache.org on 2012/07/07 07:30:40 UTC
svn commit: r1358506 - in /commons/proper/compress/trunk/src: changes/
main/java/org/apache/commons/compress/archivers/
test/java/org/apache/commons/compress/archivers/ test/resources/
Author: bodewig
Date: Sat Jul 7 05:30:40 2012
New Revision: 1358506
URL: http://svn.apache.org/viewvc?rev=1358506&view=rev
Log:
COMPRESS-191 ArchiveStreamFactory false positive for tar format. Submitted by Jukka Zitting
Added:
commons/proper/compress/trunk/src/test/resources/testAIFF.aif (props changed)
- copied unchanged from r1358501, tika/trunk/tika-parsers/src/test/resources/test-documents/testAIFF.aif
Modified:
commons/proper/compress/trunk/src/changes/changes.xml
commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
Modified: commons/proper/compress/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/changes/changes.xml?rev=1358506&r1=1358505&r2=1358506&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/changes/changes.xml (original)
+++ commons/proper/compress/trunk/src/changes/changes.xml Sat Jul 7 05:30:40 2012
@@ -42,6 +42,18 @@ The <action> type attribute can be add,u
<title>commons-compress</title>
</properties>
<body>
+ <release version="1.5" date="not released, yet"
+ description="Release 1.5">
+ <action type="fix" date="2012-07-07" issue="COMPRESS-191"
+ due-to="Jukka Zitting">
+ ArchiveStreamFactory's tar stream detection created false
+ positives for AIFF files.
+ </action>
+ <action type="update" date="2012-07-07" issue="COMPRESS-191"
+ due-to="Jukka Zitting">
+ TarArchiveEntry now has a method to verify its checksum.
+ </action>
+ </release>
<release version="1.4.1" date="2012-05-23"
description="Release 1.4.1">
<action type="fix" date="2012-05-20">
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java?rev=1358506&r1=1358505&r2=1358506&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java (original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java Sat Jul 7 05:30:40 2012
@@ -240,8 +240,10 @@ public class ArchiveStreamFactory {
if (signatureLength >= 512) {
try {
TarArchiveInputStream tais = new TarArchiveInputStream(new ByteArrayInputStream(tarheader));
- tais.getNextEntry();
- return new TarArchiveInputStream(in);
+ // COMPRESS-191 - verify the header checksum
+ if (tais.getNextTarEntry().isCheckSumOK()) {
+ return new TarArchiveInputStream(in);
+ }
} catch (Exception e) { // NOPMD
// can generate IllegalArgumentException as well
// as IOException
Modified: commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java?rev=1358506&r1=1358505&r2=1358506&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java (original)
+++ commons/proper/compress/trunk/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java Sat Jul 7 05:30:40 2012
@@ -21,7 +21,10 @@ package org.apache.commons.compress.arch
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
import org.junit.Test;
@@ -41,4 +44,23 @@ public class ArchiveStreamFactoryTest {
}
}
-}
\ No newline at end of file
+ /**
+ * see https://issues.apache.org/jira/browse/COMPRESS-191
+ */
+ @Test
+ public void aiffFilesAreNoTARs() throws Exception {
+ InputStream is = null;
+ try {
+ is = new BufferedInputStream(new FileInputStream("src/test/resources/testAIFF.aif"));
+ new ArchiveStreamFactory().createArchiveInputStream(is);
+ fail("created an input stream for a non-archive");
+ } catch (ArchiveException ae) {
+ assertTrue(ae.getMessage().startsWith("No Archiver found"));
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+ }
+
+}
Propchange: commons/proper/compress/trunk/src/test/resources/testAIFF.aif
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: commons/proper/compress/trunk/src/test/resources/testAIFF.aif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream