tag 521613 upstream patch
forwarded 521613 http://rt.cpan.org/Ticket/Display.html?id=44680
thanks

On Sat, Mar 28, 2009 at 11:55:11PM +0100, Vincent Lefevre wrote:
> Package: perl-modules
> Version: 5.10.0-19
> Severity: important
> 
> [Severity set to important because of possible data loss due to
> incorrect integrity checking.]

That's stretching it a bit IMO...

> The following script (named tar-test below), that outputs file names
> from tar files, doesn't detect some bad tar files.

I sent the attached patch upstream, waiting for comments now.

Thanks for your report,
-- 
Niko Tyni   [email protected]
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" );
+}
+

Reply via email to