Skip to content

Commit ce4bf4c

Browse files
committed
Use apache-commons-compress for bzip2 compression/decompression
Plexus Archiver contains old bzip2 compression and decompression code which is appearently forked from Apache Ant. The same code is currently maintained as part of Apache Commons Compress. The bundled bzip2 code is very outdated. It has several bugs, serious performance problems, including CVE-2012-2098 vulnerability, which can be used to cause denial of service. To fix security vulnerability and prevent future problems bundled bzip2 code is removed and replaced by calls to Apache Commons Compress library.
1 parent a82c2b4 commit ce4bf4c

File tree

9 files changed

+16
-3182
lines changed

9 files changed

+16
-3182
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@
5757
<artifactId>plexus-io</artifactId>
5858
<version>2.0.6</version>
5959
</dependency>
60+
<dependency>
61+
<groupId>org.apache.commons</groupId>
62+
<artifactId>commons-compress</artifactId>
63+
<version>1.5</version>
64+
</dependency>
6065
<dependency>
6166
<groupId>junit</groupId>
6267
<artifactId>junit</artifactId>

src/main/java/org/codehaus/plexus/archiver/bzip2/BZip2Compressor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* limitations under the License.
1818
*/
1919

20+
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
2021
import org.codehaus.plexus.archiver.ArchiverException;
2122
import org.codehaus.plexus.archiver.util.Compressor;
2223
import org.codehaus.plexus.util.IOUtil;
@@ -31,7 +32,7 @@
3132
public class BZip2Compressor
3233
extends Compressor
3334
{
34-
private CBZip2OutputStream zOut;
35+
private BZip2CompressorOutputStream zOut;
3536

3637
/**
3738
* perform the GZip compression operation.
@@ -45,7 +46,7 @@ public void compress()
4546
new BufferedOutputStream( new FileOutputStream( getDestFile() ) );
4647
bos.write( 'B' );
4748
bos.write( 'Z' );
48-
zOut = new CBZip2OutputStream( bos );
49+
zOut = new BZip2CompressorOutputStream( bos );
4950
compress( getSource(), zOut );
5051
}
5152
catch ( IOException ioe )

src/main/java/org/codehaus/plexus/archiver/bzip2/BZip2Constants.java

Lines changed: 0 additions & 110 deletions
This file was deleted.

src/main/java/org/codehaus/plexus/archiver/bzip2/BZip2UnArchiver.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.IOException;
2525
import java.io.InputStream;
2626

27+
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
2728
import org.codehaus.plexus.archiver.AbstractUnArchiver;
2829
import org.codehaus.plexus.archiver.ArchiverException;
2930
import org.codehaus.plexus.util.IOUtil;
@@ -53,7 +54,7 @@ protected void execute()
5354
+ getDestFile().getAbsolutePath() );
5455

5556
FileOutputStream out = null;
56-
CBZip2InputStream zIn = null;
57+
BZip2CompressorInputStream zIn = null;
5758
FileInputStream fis = null;
5859
BufferedInputStream bis = null;
5960
try
@@ -90,7 +91,7 @@ protected void execute()
9091
}
9192
}
9293

93-
public static CBZip2InputStream getBZip2InputStream( InputStream bis )
94+
public static BZip2CompressorInputStream getBZip2InputStream( InputStream bis )
9495
throws IOException
9596
{
9697
int b = bis.read();
@@ -103,7 +104,7 @@ public static CBZip2InputStream getBZip2InputStream( InputStream bis )
103104
{
104105
return null;
105106
}
106-
return new CBZip2InputStream( bis );
107+
return new BZip2CompressorInputStream( bis );
107108
}
108109

109110
protected void execute( String path, File outputDirectory )

0 commit comments

Comments
 (0)