Archive::Tar fails to read tar files after a first error.
For instance, consider the following script:
------------------------------------------------------------
#!/usr/bin/env perl
use Archive::Tar;
$Archive::Tar::WARN = 0;
foreach my $file (@ARGV)
{
my $tar = Archive::Tar->new;
if (defined $tar->read($file))
{
my $err = $tar->error();
warn "$err ($file)\n" if $err ne '';
}
else
{
warn "Cannot read tar file $file\n";
}
}
------------------------------------------------------------
Create a tar file tst.tar. As shown below, when tst.tar is read
without an error first, no problems. But if one provides a file
that is not a tar file first, one also gets an error for tst.tar!
$ script.pl tst.tar tst.tar
$ script.pl /etc/debian_version tst.tar
Cannot read tar file /etc/debian_version
Cannot read enough bytes from the tarfile (tst.tar)
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.30-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.ISO8859-1 (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Versions of packages perl-modules depends on:
ii perl 5.10.0-24 Larry Wall's Practical Extraction
perl-modules recommends no packages.
perl-modules suggests no packages.
-- no debconf information
--
To UNSUBSCRIBE, email to debian-bugs-...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org
On Fri, Jul 31, 2009 at 02:52:16AM +0200, Vincent Lefevre wrote:
> Package: perl-modules
> Version: 5.10.0-24
> Severity: normal
>
> Archive::Tar fails to read tar files after a first error.
I believe it doesn't actually fail.
> foreach my $file (@ARGV)
> {
> my $tar = Archive::Tar->new;
> if (defined $tar->read($file))
> {
> my $err = $tar->error();
> warn "$err ($file)\n" if $err ne '';
> }
> else
> {
> warn "Cannot read tar file $file\n";
> }
> }
You aren't testing for any error indicator: the error string only gets
set when read() returns false. The value you're seeing is left over from
the previous read() call. My tests indicate the second file is actually
read successfully and read() returns a positive value.
The fact that error() is an object method but returns a module-wide
(effectively global) value does seem to me like a design oversight and
could at least be documented better. Downgrading the severity, I'll see
about sending a patch upstream.
--
Niko Tyni nt...@debian.org
--
Vincent Lefèvre <vin...@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
IMHO, this is more than a documentation error. This is bug that should
be fixed or the object method should be removed.
--
Vincent Lefèvre <vin...@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
--