Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#539355: perl-modules: Archive::Tar fails to read tar files after a first error

36 views
Skip to first unread message

Vincent Lefevre

unread,
Jul 30, 2009, 9:00:17 PM7/30/09
to
Package: perl-modules
Version: 5.10.0-24
Severity: normal

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

Niko Tyni

unread,
Aug 26, 2009, 4:30:13 PM8/26/09
to
retitle 539355 improve Archive::Tar::error() documentation
severity 539355 minor
thanks

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 Lefevre

unread,
Aug 26, 2009, 8:00:11 PM8/26/09
to
It seems that I forgot to mention that I had reported the problem
upstream too: http://rt.cpan.org/Public/Bug/Display.html?id=48879

--
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)

Vincent Lefevre

unread,
Aug 26, 2009, 8:00:12 PM8/26/09
to
On 2009-08-26 23:11:28 +0300, Niko Tyni wrote:
> 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.

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)

--

0 new messages