develooper Front page | perl.perl5.changes | Postings from August 2022

[Perl/perl5] 7f845d: op.c - Restrict nested eval/BEGIN blocks to auser...

From:
Yves Orton via perl5-changes
Date:
August 28, 2022 13:11
Subject:
[Perl/perl5] 7f845d: op.c - Restrict nested eval/BEGIN blocks to auser...
Message ID:
Perl/perl5/push/refs/heads/yves/eval_begin_nest_depth/fac867-7f845d@github.com
  Branch: refs/heads/yves/eval_begin_nest_depth
  Home:   https://github.com/Perl/perl5
  Commit: 7f845d088284cf66333ed710c623b15ccd43a46d
      https://github.com/Perl/perl5/commit/7f845d088284cf66333ed710c623b15ccd43a46d
  Author: Yves Orton <demerphq@gmail.com>
  Date:   2022-08-28 (Sun, 28 Aug 2022)

  Changed paths:
    M INSTALL
    M embedvar.h
    M intrpvar.h
    M op.c
    M perl.h
    M pod/perldelta.pod
    M pod/perldiag.pod
    M pod/perlfunc.pod
    M pod/perlvar.pod
    M sv.c
    M t/op/eval.t

  Log Message:
  -----------
  op.c - Restrict nested eval/BEGIN blocks to a user controllable maximum

Nested BEGIN blocks can cause us to segfault by exhausting
the C stack. Eg:

    perl -le'sub f { eval "BEGIN { f() }" } f()'

will segfault. This adds a new interpreter var PL_eval_begin_nest_depth
to keep track of how many layer of eval/BEGIN we have seen, and a new
reserved variable called ${^MAX_NESTED_EVAL_BEGIN_BLOCKS} which can be
used to raise or lower the limit. When set to 0 it blocks BEGIN entirely,
which might be useful from time to time.

This fixes https://github.com/Perl/perl5/issues/20176





nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About