This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Archive::Tar to 1.48
authorJos I. Boumans <jos@dwim.org>
Sat, 2 May 2009 13:56:14 +0000 (15:56 +0200)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sat, 2 May 2009 13:56:14 +0000 (15:56 +0200)
lib/Archive/Tar.pm
lib/Archive/Tar/t/04_resolved_issues.t
lib/Archive/Tar/t/src/header/signed.tar.packed
lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed
lib/Archive/Tar/t/src/linktest/linktest_with_dir.tar.packed
lib/Archive/Tar/t/src/long/bar.tar.packed
lib/Archive/Tar/t/src/long/foo.tbz.packed
lib/Archive/Tar/t/src/long/foo.tgz.packed
lib/Archive/Tar/t/src/short/bar.tar.packed
lib/Archive/Tar/t/src/short/foo.tbz.packed
lib/Archive/Tar/t/src/short/foo.tgz.packed

index 09dab10..b504881 100644 (file)
@@ -31,7 +31,7 @@ use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK $CHOWN $CHMOD
 $DEBUG                  = 0;
 $WARN                   = 1;
 $FOLLOW_SYMLINK         = 0;
-$VERSION                = "1.46";
+$VERSION                = "1.48";
 $CHOWN                  = 1;
 $CHMOD                  = 1;
 $DO_NOT_USE_PREFIX      = 0;
@@ -323,6 +323,13 @@ sub _read_tar {
                 $self->_error( qq[Cannot read compressed format in tar-mode] );
                 return;
             }
+            
+            ### size is < HEAD, which means a corrupted file, as the minimum
+            ### length is _at least_ HEAD
+            if (length $chunk != HEAD) {
+                $self->_error( qq[Cannot read enough bytes from the tarfile] );
+                return;
+            }
         }
 
         ### if we can't read in all bytes... ###
index 89756cd..9bb3d33 100644 (file)
@@ -167,3 +167,27 @@ use_ok( $FileClass );
         ok( $file->validate,    "           File validates" );
     }        
 }
+
+### return error properly on corrupted archives
+### Addresses RT #44680: Improve error reporting on short corrupted archives
+{   ok( 1,                      "Testing bug 44680" );
+
+    {   ### XXX whitebox test -- resetting the error string
+        no warnings 'once'; 
+        $Archive::Tar::error = "";
+    }
+
+    my $src = File::Spec->catfile( qw[src short b] );
+    my $tar = $Class->new;
+    
+    isa_ok( $tar, $Class,       "   Object" );
+    
+    
+    ### we quell the error on STDERR
+    local $Archive::Tar::WARN = 0;
+
+    ok( !$tar->read( $src ),    "   No files in the corrupted archive" );
+    like( $tar->error, qr/enough bytes/,
+                                "       Expected error reported" );
+}
+
index e8d5bc8..1fa99b3 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/header/signed.tar lib/Archive/Tar/t/src/header/signed.tar.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:41 2009
 #########################################################################
 __UU__
 MPZ3#I,.D````````````````````````````````````````````````````
index 2cd0987..897641e 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M;&EN:W1E<W0O;&EN:P``````````````````````````````````````````
index 50ecaeb..a3dd098 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/linktest/linktest_with_dir.tar lib/Archive/Tar/t/src/linktest/linktest_with_dir.tar.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M;&EN:W1E<W0O;W)I9R\`````````````````````````````````````````
index 1379fee..c06973e 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/long/bar.tar lib/Archive/Tar/t/src/long/bar.tar.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M8P``````````````````````````````````````````````````````````
index 705f5bf..8ca9f69 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/long/foo.tbz lib/Archive/Tar/t/src/long/foo.tbz.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M0EIH.3%!62936=873NT``9C_A._0`DA``_^`0`0)`._OGJ```40(,`%X9`8`
index 6de253c..e481ec5 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/long/foo.tgz lib/Archive/Tar/t/src/long/foo.tgz.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M'XL(`````````^W72VZ#,!`&8*]S"BY`F,$/MCT`ET")25`<D"A1Q.UKR*M1
index 18399eb..f507bbb 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/short/bar.tar lib/Archive/Tar/t/src/short/bar.tar.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M8P``````````````````````````````````````````````````````````
index ff0f7e4..7fcb8ec 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/short/foo.tbz lib/Archive/Tar/t/src/short/foo.tbz.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M0EIH.3%!62936>GH,8X``)O[A.90`D!``'^```#O*1X```%`""``E(*JGDA#
index 67af0ed..61827fe 100644 (file)
@@ -10,7 +10,7 @@ To recreate it use the following command:
 
      uupacktool.pl -p lib/Archive/Tar/t/src/short/foo.tgz lib/Archive/Tar/t/src/short/foo.tgz.packed
 
-Created at Thu Mar  5 17:07:54 2009
+Created at Tue Apr 21 11:50:42 2009
 #########################################################################
 __UU__
 M'XL(`````````^W300K",!"%X5GW%#G"3-JFYREJ080NJKU_A^A"$.RJ(\+_