perl.patch 1.0 KB

123456789101112131415161718192021222324252627
  1. "A security hole has been discovered in Safe.pm. When a Safe compartment
  2. has already been used, there's no guarantee that it's safe any longer,
  3. because there's a way for code executed within the Safe compartment to
  4. alter its operation mask. (Thus, programs that use a Safe compartment
  5. only once aren't affected by this bug.)"
  6. --- ext/Opcode/Safe.pm.orig
  7. +++ ext/Opcode/Safe.pm
  8. @@ -213,7 +213,7 @@
  9. # Create anon sub ref in root of compartment.
  10. # Uses a closure (on $expr) to pass in the code to be executed.
  11. # (eval on one line to keep line numbers as expected by caller)
  12. - my $evalcode = sprintf('package %s; sub { eval $expr; }', $root);
  13. + my $evalcode = sprintf('package %s; sub { @_ = (); eval $expr; }', $root);
  14. my $evalsub;
  15. if ($strict) { use strict; $evalsub = eval $evalcode; }
  16. @@ -227,7 +227,7 @@
  17. my $root = $obj->{Root};
  18. my $evalsub = eval
  19. - sprintf('package %s; sub { do $file }', $root);
  20. + sprintf('package %s; sub { @_ = (); do $file }', $root);
  21. return Opcode::_safe_call_sv($root, $obj->{Mask}, $evalsub);
  22. }