Skip to content

Commit

Permalink
check for embedded NUL char in jl_load (for include) (#16233)
Browse files Browse the repository at this point in the history
* check for embedded NUL char in jl_load (for include)

* use Core.include in test
  • Loading branch information
stevengj authored and tkelman committed May 21, 2016
1 parent 99bf23d commit cac984e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ jl_value_t *jl_parse_eval_all(const char *fname, size_t len,
fl_free_gc_handles(fl_ctx, 1);
}
else {
assert(memchr(fname, 0, len) == NULL); // was checked already in jl_load
ast = fl_applyn(fl_ctx, 1, symbol_value(symbol(fl_ctx, "jl-parse-file")), f);
}
fl_free_gc_handles(fl_ctx, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ JL_DLLEXPORT jl_value_t *jl_toplevel_eval(jl_value_t *v)

JL_DLLEXPORT jl_value_t *jl_load(const char *fname, size_t len)
{
if (NULL != memchr(fname, 0, len))
jl_exceptionf(jl_argumenterror_type, "file name may not contain \\0");
if (jl_current_module->istopmod) {
jl_printf(JL_STDOUT, "%s\r\n", fname);
#ifdef _OS_WINDOWS_
Expand Down
2 changes: 2 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ using Base.Test

@test @__LINE__ == 5

@test_throws ArgumentError Core.include("test_sourcepath.jl\0")

include("test_sourcepath.jl")
thefname = "the fname!//\\&\0\1*"
@test include_string("include_string_test() = @__FILE__", thefname)() == Base.source_path()
Expand Down

0 comments on commit cac984e

Please sign in to comment.