summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-10-04 20:01:54 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-10-04 20:01:54 +0000
commitd00660f465786916fefe3ea27590f9ad4976afab (patch)
tree79bef81573f4f0480d80b32143c17347cf7763ae /ext
parent33f7e1aa9bf0173d92dc0c0b35d57754dbf6c87e (diff)
downloadperl-d00660f465786916fefe3ea27590f9ad4976afab.tar.gz
Complement to change #17976 :
there was a similar bug on rdo(). Increment $Safe::VERSION. p4raw-link: @17976 on //depot/perl: 33f7e1aa9bf0173d92dc0c0b35d57754dbf6c87e p4raw-id: //depot/perl@17977
Diffstat (limited to 'ext')
-rw-r--r--ext/Opcode/Safe.pm8
-rw-r--r--ext/Safe/safe3.t21
2 files changed, 22 insertions, 7 deletions
diff --git a/ext/Opcode/Safe.pm b/ext/Opcode/Safe.pm
index 8d875ef5b2..ad46bbbe69 100644
--- a/ext/Opcode/Safe.pm
+++ b/ext/Opcode/Safe.pm
@@ -3,7 +3,7 @@ package Safe;
use 5.003_11;
use strict;
-our $VERSION = "2.07";
+our $VERSION = "2.08";
use Carp;
@@ -155,7 +155,7 @@ sub share_from {
my $no_record = shift || 0;
my $root = $obj->root();
croak("vars not an array ref") unless ref $vars eq 'ARRAY';
- no strict 'refs';
+ no strict 'refs';
# Check that 'from' package actually exists
croak("Package \"$pkg\" does not exist")
unless keys %{"$pkg\::"};
@@ -190,7 +190,7 @@ sub share_record {
sub share_redo {
my $obj = shift;
my $shares = \%{$obj->{Shares} ||= {}};
- my($var, $pkg);
+ my($var, $pkg);
while(($var, $pkg) = each %$shares) {
# warn "share_redo $pkg\:: $var";
$obj->share_from($pkg, [ $var ], 1);
@@ -228,7 +228,7 @@ sub rdo {
my $root = $obj->{Root};
my $evalsub = eval
- sprintf('package %s; sub { do $file }', $root);
+ sprintf('package %s; sub { @_ = (); do $file }', $root);
return Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub);
}
diff --git a/ext/Safe/safe3.t b/ext/Safe/safe3.t
index c924762faa..6265d146e3 100644
--- a/ext/Safe/safe3.t
+++ b/ext/Safe/safe3.t
@@ -18,16 +18,31 @@ BEGIN {
use strict;
use warnings;
use POSIX qw(ceil);
-use Test::More tests => 1;
+use Test::More tests => 2;
use Safe;
my $safe = new Safe;
$safe->deny('add');
+my $masksize = ceil( Opcode::opcodes / 8 );
# Attempt to change the opmask from within the safe compartment
-$safe->reval( qq{\$_[1] = q/\0/ x } . ceil( Opcode::opcodes / 8 ) );
+$safe->reval( qq{\$_[1] = qq/\0/ x } . $masksize );
# Check that it didn't work
$safe->reval( q{$x + $y} );
like( $@, qr/^'?addition \(\+\)'? trapped by operation mask/,
- 'opmask still in place' );
+ 'opmask still in place with reval' );
+
+my $safe2 = new Safe;
+$safe2->deny('add');
+
+open my $fh, '>nasty.pl' or die "Can't write nasty.pl: $!\n";
+print $fh <<EOF;
+\$_[1] = "\0" x $masksize;
+EOF
+close $fh;
+$safe2->rdo('nasty.pl');
+$safe2->reval( q{$x + $y} );
+like( $@, qr/^'?addition \(\+\)'? trapped by operation mask/,
+ 'opmask still in place with rdo' );
+END { unlink 'nasty.pl' }