From: http://rt.cpan.org/Public/Bug/Display.html?id=36982
http://rt.perl.org/rt3/Public/Bug/Display.html?id=54566
Perl bug 54566 patch from:
http://cvs.fedoraproject.org/viewvc/devel/perl/perl-5.10.0-bz448392.patch?view=co
diff -Naur perl-5.10.0.orig/lib/File/CVE-2008-2827.t perl-5.10.0/lib/File/CVE-2008-2827.t
old
|
new
|
|
| 1 | #!perl -w |
| 2 | |
| 3 | # Test case derived from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487319 |
| 4 | |
| 5 | my $foo = "foo-$$"; |
| 6 | my $bar = "bar-$$"; |
| 7 | |
| 8 | die "Not clean [$foo] [$bar]" if -e $foo || -e $bar; |
| 9 | |
| 10 | eval { |
| 11 | symlink($foo, $bar) || die "Can't symlink $foo --> $bar"; |
| 12 | }; |
| 13 | if ($@) { |
| 14 | print "1..0 # Skipped: Only systems that can do symlinks are affected\n"; |
| 15 | print "$@\n"; |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | use Test; |
| 20 | plan tests => 5; |
| 21 | |
| 22 | umask(0027); |
| 23 | |
| 24 | # touch foo |
| 25 | open(my $fh, ">", $foo) || die "Can't create $foo\n"; |
| 26 | close($fh); |
| 27 | |
| 28 | my $m = (stat $foo)[2]; |
| 29 | ok(defined $m); |
| 30 | |
| 31 | require File::Path; |
| 32 | ok(File::Path::rmtree($bar)); |
| 33 | ok(!-e $bar); |
| 34 | |
| 35 | # If the mode of $foo changed as a result of removing $bar then we are vulnerable |
| 36 | ok($m, (stat $foo)[2]); |
| 37 | |
| 38 | unlink($foo); |
| 39 | ok(!-e $foo); |
diff -Naur perl-5.10.0.orig/lib/File/Path.pm perl-5.10.0/lib/File/Path.pm
old
|
new
|
|
350 | 350 | next ROOT_DIR; |
351 | 351 | } |
352 | 352 | |
353 | | my $nperm = $perm & 07777 | 0600; |
354 | | if ($nperm != $perm and not chmod $nperm, $root) { |
355 | | if ($Force_Writeable) { |
| 353 | if ($Force_Writeable) { |
| 354 | my $nperm = $perm & 07777 | 0600; |
| 355 | if ($nperm != $perm and not chmod $nperm, $root) { |
356 | 356 | _error($arg, "cannot make file writeable", $canon); |
357 | 357 | } |
358 | 358 | } |
diff -Naur perl-5.10.0.orig/mg.c perl-5.10.0/mg.c
old
|
new
|
|
1543 | 1543 | stash = GvSTASH( |
1544 | 1544 | SvTYPE(mg->mg_obj) == SVt_PVGV |
1545 | 1545 | ? (GV*)mg->mg_obj |
1546 | | : (GV*)SvMAGIC(mg->mg_obj)->mg_obj |
| 1546 | : (GV*)mg_find(mg->mg_obj, PERL_MAGIC_isa)->mg_obj |
1547 | 1547 | ); |
1548 | 1548 | |
1549 | 1549 | mro_isa_changed_in(stash); |