Skip to content

Commit 3a379a3

Browse files
Stanislav Ochotnickykrosenvold
authored andcommitted
Fix double 'BZBZ' magic string regression in bzip2 archives
Commit ce4bf4c introduced a regression where archives created with plexus-archiver would only be opened by plexus-archiver and no other tool. In similar fashion plexus-archiver was unable to extract proper archives because it removed "BZ" magic header before passing the stream to commons-compress Signed-off-by: Kristian Rosenvold <[email protected]>
1 parent 496a706 commit 3a379a3

File tree

4 files changed

+0
-22
lines changed

4 files changed

+0
-22
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ public void compress()
4444
{
4545
BufferedOutputStream bos =
4646
new BufferedOutputStream( new FileOutputStream( getDestFile() ) );
47-
bos.write( 'B' );
48-
bos.write( 'Z' );
4947
zOut = new BZip2CompressorOutputStream( bos );
5048
compress( getSource(), zOut );
5149
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@ protected void execute()
9494
public static BZip2CompressorInputStream getBZip2InputStream( InputStream bis )
9595
throws IOException
9696
{
97-
int b = bis.read();
98-
if ( b != 'B' )
99-
{
100-
return null;
101-
}
102-
b = bis.read();
103-
if ( b != 'Z' )
104-
{
105-
return null;
106-
}
10797
return new BZip2CompressorInputStream( bis );
10898
}
10999

src/main/java/org/codehaus/plexus/archiver/tar/TarArchiver.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,6 @@ private OutputStream compress( final OutputStream ostream )
631631
}
632632
else if ( BZIP2.equals( value ) )
633633
{
634-
ostream.write( 'B' );
635-
ostream.write( 'Z' );
636634
return new BZip2CompressorOutputStream( ostream );
637635
}
638636
return ostream;

src/main/java/org/codehaus/plexus/archiver/tar/TarUnArchiver.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,6 @@ private InputStream decompress( final File file, final InputStream istream )
192192
}
193193
else if ( BZIP2.equals( value ) )
194194
{
195-
final char[] magic = new char[]{'B', 'Z'};
196-
for ( int i = 0; i < magic.length; i++ )
197-
{
198-
if ( istream.read() != magic[ i ] )
199-
{
200-
throw new ArchiverException( "Invalid bz2 file." + file.toString() );
201-
}
202-
}
203195
return new BZip2CompressorInputStream( istream );
204196
}
205197
return istream;

0 commit comments

Comments
 (0)