Commit | Line | Data |
7a823c14 |
1 | #!perl -w |
33f7e1aa |
2 | |
3 | BEGIN { |
ac5e3691 |
4 | require Config; import Config; |
5 | if ($Config{'extensions'} !~ /\bOpcode\b/ |
6 | && $Config{'extensions'} !~ /\bPOSIX\b/ |
7 | && $Config{'osname'} ne 'VMS') |
8 | { |
9 | print "1..0\n"; |
10 | exit 0; |
33f7e1aa |
11 | } |
12 | } |
13 | |
14 | use strict; |
15 | use warnings; |
16 | use POSIX qw(ceil); |
d00660f4 |
17 | use Test::More tests => 2; |
33f7e1aa |
18 | use Safe; |
19 | |
20 | my $safe = new Safe; |
21 | $safe->deny('add'); |
22 | |
d00660f4 |
23 | my $masksize = ceil( Opcode::opcodes / 8 ); |
33f7e1aa |
24 | # Attempt to change the opmask from within the safe compartment |
d00660f4 |
25 | $safe->reval( qq{\$_[1] = qq/\0/ x } . $masksize ); |
33f7e1aa |
26 | |
27 | # Check that it didn't work |
28 | $safe->reval( q{$x + $y} ); |
c3c3bebb |
29 | # Written this way to keep the Test::More that comes with perl 5.6.2 happy |
7a823c14 |
30 | ok( $@ =~ /^'?addition \(\+\)'? trapped by operation mask/, |
d00660f4 |
31 | 'opmask still in place with reval' ); |
32 | |
33 | my $safe2 = new Safe; |
34 | $safe2->deny('add'); |
35 | |
36 | open my $fh, '>nasty.pl' or die "Can't write nasty.pl: $!\n"; |
37 | print $fh <<EOF; |
38 | \$_[1] = "\0" x $masksize; |
39 | EOF |
40 | close $fh; |
41 | $safe2->rdo('nasty.pl'); |
42 | $safe2->reval( q{$x + $y} ); |
c3c3bebb |
43 | # Written this way to keep the Test::More that comes with perl 5.6.2 happy |
7a823c14 |
44 | ok( $@ =~ /^'?addition \(\+\)'? trapped by operation mask/, |
d00660f4 |
45 | 'opmask still in place with rdo' ); |
46 | END { unlink 'nasty.pl' } |