Skip Menu |

This queue is for tickets about the Archive-Tar CPAN distribution.

Report information
The Basics
Id: 41798
Status: resolved
Priority: 0/
Queue: Archive-Tar

People
Owner: Nobody in particular
Requestors: BARTL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.42
Fixed in: (no value)



Subject: Nonempty $\ when writing a TAR file produces a corrupt TAR file
This is an ancient bug (tested for presence in 1.29, and it is there). If $\ is not empty, for example when set to "\n", then Archive::Tar produces a corrupt tar file. For example: #!/usr/bin/perl -wl use Archive::Tar; my $tarfile = shift || die "Please specify a .tar or .tar.gz file"; (my $out = $tarfile) =~ s/\.tar(?:\.gz)?$/.out.tar/; print "Version: " . Archive::Tar->VERSION; { # copy tar file my $tar = Archive::Tar->new; $tar->read($tarfile); my @files = $tar->list_files; print foreach @files; $tar->write($out); } { # check copy my $tar = Archive::Tar->new; $tar->read($out); use Data::Dumper; my @files = $tar->get_files; foreach my $file (@files) { print Dumper([ $file->name, $file->type, $file->mode ]); } } Usually you get error messages in the second block (the check block). For example, with the archive Archive-Tar-1.29.tar.gz (from CPAN), the error is (after the files list): bin: checksum error at test.pl line 18 : checksum error at test.pl line 18 Invalid header block at offset unknown at test.pl line 18 Invalid header block at offset unknown at test.pl line 18 Invalid header block at offset unknown at test.pl line 18 Invalid header block at offset unknown at test.pl line 18 Invalid header block at offset unknown at test.pl line 18 ts this help message =head1 SEE ALSO tar(1), L<Archive::Tar>. =cut: checksum error at test.pl line 18 $VAR1 = [ 'Archive-Tar-1.29', '5', 493 ]; Inspecting the copy file with a hex editor, you can see the header per file entry is 513 bytes long. Fix: in sub "write", put the line local $\; somewhere before the line unless( print $handle $header ) { (line 1202 in Archive::Tar 1.42) (preferably before the main loop)
On Wed Dec 17 18:01:41 2008, BARTL wrote: Show quoted text
> This is an ancient bug (tested for presence in 1.29, and it is there). > > If $\ is not empty, for example when set to "\n", then Archive::Tar > produces a corrupt tar file.
Thanks for the report, fix is applied and will be in the next release.