Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: ntyni [...] iki.fi
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.46
Fixed in: (no value)



Hi, as reported by Vincent Lefevre in <http://bugs.debian.org/521613>, Archive::Tar->read() could check a bit better for errors. Corrupted archives shorter than 512 bytes will not currently set the error string. I'm attaching a test case and a proposed patch for this. Thanks for your work, -- Niko Tyni ntyni@debian.org
Subject: 521613.patch
diff --git a/lib/Archive/Tar.pm b/lib/Archive/Tar.pm index 09dab10..117ca35 100644 --- a/lib/Archive/Tar.pm +++ b/lib/Archive/Tar.pm @@ -323,6 +323,10 @@ sub _read_tar { $self->_error( qq[Cannot read compressed format in tar-mode] ); return; } + if (length $chunk != HEAD) { + $self->_error( qq[Cannot read enough bytes from the tarfile] ); + return; + } } ### if we can't read in all bytes... ### diff --git a/t/04_resolved_issues.t b/t/04_resolved_issues.t index 89756cd..e4e82a1 100644 --- a/t/04_resolved_issues.t +++ b/t/04_resolved_issues.t @@ -167,3 +167,15 @@ use_ok( $FileClass ); ok( $file->validate, " File validates" ); } } + +### return error properly on corrupted archives +{ ok( 1, "Testing error reporting with a short corrupted archive" ); + no warnings 'once'; $Archive::Tar::error = ""; + my $src = File::Spec->catfile( qw[src short b] ); + my $tar = $Class->new; + + isa_ok( $tar, $Class, " Object" ); + ok( !$tar->read( $src ), " No files in the corrupted archive" ); + ok( $tar->error ne "", " Nonempty error when reading the corrupted archive" ); +} +
Subject: Re: [rt.cpan.org #44680] Improve error reporting on short corrupted archives
Date: Mon, 30 Mar 2009 22:28:11 +0300
To: Bugs in Archive-Tar via RT <bug-Archive-Tar [...] rt.cpan.org>
From: Niko Tyni <ntyni [...] iki.fi>
On Mon, Mar 30, 2009 at 03:19:13PM -0400, Bugs in Archive-Tar via RT wrote: Show quoted text
> This message has been automatically generated in response to the > creation of a trouble ticket regarding: > "",
Oops, apologies for the missing subject. I think I got it sorted out with the web interface. -- Niko Tyni ntyni@debian.org
Hi, On Mon Mar 30 15:19:12 2009, ntyni@iki.fi wrote: Show quoted text
> as reported by Vincent Lefevre in <http://bugs.debian.org/521613>, > Archive::Tar->read() could check a bit better for errors. Corrupted > archives shorter than 512 bytes will not currently set the error string. > > I'm attaching a test case and a proposed patch for this. > > Thanks for your work,
Thanks for the most excellent report and patch. They are applied with minor tweaks and will be part of the next stable release. Cheers,