In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/08f800f8519574aea9e744ff83230fb93772652b?hp=fef6692e28d019582497b48b58e1773d181d6ac7>
- Log ----------------------------------------------------------------- commit 08f800f8519574aea9e744ff83230fb93772652b Author: Father Chrysostomos <[email protected]> Date: Wed May 18 18:07:37 2016 -0700 [perl #128182] Fix crash with require $nonstring If something other than a plain string (e.g. a reference or typeglob) whose stringified form contains a null character is passed to require() or do(), it crashes, as of v5.19.3-130-gc8028aa, because the code in question that handles the error tries to read fields of the scalar that are only valid if it is a string internally. M pp_ctl.c M t/op/require_errors.t commit 482e4418cbff3a580fd0c63dd1918d375a086700 Author: Father Chrysostomos <[email protected]> Date: Wed May 18 17:54:28 2016 -0700 lexsub.t: Remove some unnecessary evals These evals were originally of the form eval {...} when I added the tests, before things were working. When I got them working, I left few evals by mistake, while removing the braces. Luckily, eval 44 produces the same thing as 44. M t/op/lexsub.t ----------------------------------------------------------------------- Summary of changes: pp_ctl.c | 4 ++-- t/op/lexsub.t | 8 ++++---- t/op/require_errors.t | 10 +++++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pp_ctl.c b/pp_ctl.c index 423691c..1e5b684 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3686,8 +3686,8 @@ S_require_file(pTHX_ SV *const sv) if (!IS_SAFE_PATHNAME(name, len, "require")) { DIE(aTHX_ "Can't locate %s: %s", - pv_escape(newSVpvs_flags("",SVs_TEMP),SvPVX(sv),SvCUR(sv), - SvCUR(sv)*2,NULL, SvUTF8(sv)?PERL_PV_ESCAPE_UNI:0), + pv_escape(newSVpvs_flags("",SVs_TEMP),name,len,len*2, + NULL, SvUTF8(sv)?PERL_PV_ESCAPE_UNI:0), Strerror(ENOENT)); } TAINT_PROPER("require"); diff --git a/t/op/lexsub.t b/t/op/lexsub.t index adccf4c..de4c074 100644 --- a/t/op/lexsub.t +++ b/t/op/lexsub.t @@ -126,11 +126,11 @@ use feature 'state'; # state { state sub foo { 44 } isnt \&::foo, \&foo, 'state sub is not stored in the package'; - is eval foo, 44, 'calling state sub from same package'; - is eval &foo, 44, 'calling state sub from same package (amper)'; + is foo, 44, 'calling state sub from same package'; + is &foo, 44, 'calling state sub from same package (amper)'; package bar; - is eval foo, 44, 'calling state sub from another package'; - is eval &foo, 44, 'calling state sub from another package (amper)'; + is foo, 44, 'calling state sub from another package'; + is &foo, 44, 'calling state sub from another package (amper)'; } package bar; is foo, 43, 'state sub falling out of scope'; diff --git a/t/op/require_errors.t b/t/op/require_errors.t index 3744f14..2215b40 100644 --- a/t/op/require_errors.t +++ b/t/op/require_errors.t @@ -8,7 +8,7 @@ BEGIN { use strict; use warnings; -plan(tests => 18); +plan(tests => 20); my $nonfile = tempfile(); @@ -139,3 +139,11 @@ like $@, qr/^Can't locate strict\.pm\\0invalid: /, 'do nul check'; eval "require strict\0::invalid;"; like $@, qr/^syntax error at \(eval \d+\) line 1/, 'parse error with \0 in barewords module names'; +# Refs and globs that stringify with embedded nulls +# These crashed from 5.20 to 5.24 [perl #128182]. +eval { no warnings 'syscalls'; require eval "qr/\0/" }; +like $@, qr/^Can't locate \(\?\^:\\0\):/, + 'require ref that stringifies with embedded null'; +eval { no strict; no warnings 'syscalls'; require *{"\0a"} }; +like $@, qr/^Can't locate \*main::\\0a:/, + 'require ref that stringifies with embedded null'; -- Perl5 Master Repository
