From: Jos I. Boumans Date: Sat, 2 May 2009 13:56:14 +0000 (+0200) Subject: Update Archive::Tar to 1.48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4feb3b720036eec7ba1546b2c13226e19c67319e;p=p5sagit%2Fp5-mst-13.2.git Update Archive::Tar to 1.48 --- diff --git a/lib/Archive/Tar.pm b/lib/Archive/Tar.pm index 09dab10..b504881 100644 --- a/lib/Archive/Tar.pm +++ b/lib/Archive/Tar.pm @@ -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... ### diff --git a/lib/Archive/Tar/t/04_resolved_issues.t b/lib/Archive/Tar/t/04_resolved_issues.t index 89756cd..9bb3d33 100644 --- a/lib/Archive/Tar/t/04_resolved_issues.t +++ b/lib/Archive/Tar/t/04_resolved_issues.t @@ -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" ); +} + diff --git a/lib/Archive/Tar/t/src/header/signed.tar.packed b/lib/Archive/Tar/t/src/header/signed.tar.packed index e8d5bc8..1fa99b3 100644 --- a/lib/Archive/Tar/t/src/header/signed.tar.packed +++ b/lib/Archive/Tar/t/src/header/signed.tar.packed @@ -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```````````````````````````````````````````````````` diff --git a/lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed b/lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed index 2cd0987..897641e 100644 --- a/lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed +++ b/lib/Archive/Tar/t/src/linktest/linktest_missing_dir.tar.packed @@ -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:W1EGH,8X``)O[A.90`D!``'^```#O*1X```%`""``E(*JGDA# diff --git a/lib/Archive/Tar/t/src/short/foo.tgz.packed b/lib/Archive/Tar/t/src/short/foo.tgz.packed index 67af0ed..61827fe 100644 --- a/lib/Archive/Tar/t/src/short/foo.tgz.packed +++ b/lib/Archive/Tar/t/src/short/foo.tgz.packed @@ -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(\+_