Skip to content

Commit

Permalink
Earlier safety check for @inc entry in pp_require.
Browse files Browse the repository at this point in the history
In order to make sure we find embedded NULs early enough, before
the directories in @inc have been through library calls that use C
strings, check each directory in pp_require before concatenating
a filename onto it.
  • Loading branch information
craigberry committed Sep 17, 2013
1 parent 21869ca commit ddc65b6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pp_ctl.c
Expand Up @@ -3969,6 +3969,8 @@ PP(pp_require)
dirlen = 0;
}

if (!IS_SAFE_SYSCALL(dir, dirlen, "@INC entry", "require"))
continue;
#ifdef VMS
if (((unixdirbuf = SvPVX(sv_2mortal(newSVpv("", VMS_MAXRSS-1)))) == NULL)
|| ((unixdir = tounixpath(dir, unixdirbuf)) == NULL))
Expand Down
2 changes: 1 addition & 1 deletion t/op/require_errors.t
Expand Up @@ -128,7 +128,7 @@ like $@, qr/^Can't locate strict\.pm\\0invalid: /, 'do nul check';
local @INC = @INC;
unshift @INC, "lib\0invalid";
eval { require "unknown.pm" };
like $WARN, qr{^Invalid \\0 character in pathname for require: lib\\0invalid/unknown\.pm at }, 'nul warning';
like $WARN, qr{^Invalid \\0 character in \@INC entry for require: lib\\0invalid at }, 'nul warning';
}
eval "require strict\0::invalid;";
like $@, qr/^syntax error at \(eval \d+\) line 1/, 'parse error with \0 in barewords module names';
Expand Down

0 comments on commit ddc65b6

Please sign in to comment.