1 --- perl-5.6.1.orig/ext/Opcode/Safe.pm
2 +++ perl-5.6.1/ext/Opcode/Safe.pm
7 -our $VERSION = "2.06";
8 +$Safe::VERSION = "2.09";
13 # the whole glob *_ rather than $_ and @_ separately, otherwise
14 # @_ in non default packages within the compartment don't work.
15 $obj->share_from('main', $default_share);
16 + Opcode::_safe_pkg_prep($obj->{Root}) if($Opcode::VERSION > 1.04);
21 my $no_record = shift || 0;
22 my $root = $obj->root();
23 croak("vars not an array ref") unless ref $vars eq 'ARRAY';
26 # Check that 'from' package actually exists
27 croak("Package \"$pkg\" does not exist")
28 unless keys %{"$pkg\::"};
32 my $shares = \%{$obj->{Shares} ||= {}};
35 while(($var, $pkg) = each %$shares) {
36 # warn "share_redo $pkg\:: $var";
37 $obj->share_from($pkg, [ $var ], 1);
39 # Create anon sub ref in root of compartment.
40 # Uses a closure (on $expr) to pass in the code to be executed.
41 # (eval on one line to keep line numbers as expected by caller)
42 - my $evalcode = sprintf('package %s; sub { eval $expr; }', $root);
43 + my $evalcode = sprintf('package %s; sub { @_ = (); eval $expr; }', $root);
46 - if ($strict) { use strict; $evalsub = eval $evalcode; }
47 - else { no strict; $evalsub = eval $evalcode; }
48 + if ($strict) { use strict; $evalsub = eval $evalcode; }
49 + else { no strict; $evalsub = eval $evalcode; }
51 return Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub);
54 my $root = $obj->{Root};
57 - sprintf('package %s; sub { do $file }', $root);
58 + sprintf('package %s; sub { @_ = (); do $file }', $root);
59 return Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub);
63 =item share (NAME, ...)
65 This shares the variable(s) in the argument list with the compartment.
66 -This is almost identical to exporting variables using the L<Exporter(3)>
67 +This is almost identical to exporting variables using the L<Exporter>
70 -Each NAME must be the B<name> of a variable, typically with the leading
71 -type identifier included. A bareword is treated as a function name.
72 +Each NAME must be the B<name> of a non-lexical variable, typically
73 +with the leading type identifier included. A bareword is treated as a
76 Examples of legal names are '$foo' for a scalar, '@foo' for an
77 array, '%foo' for a hash, '&foo' or 'foo' for a subroutine and '*foo'
79 Any attempt by the code in STRING to use an operator which is not permitted
80 by the compartment will cause an error (at run-time of the main program
81 but at compile-time for the code in STRING). The error is of the form
82 -"%s trapped by operation mask operation...".
83 +"'%s' trapped by operation mask...".
85 If an operation is trapped in this way, then the code in STRING will
86 not be executed. If such a trapped operation occurs or any other