Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for embedded NUL char in jl_load (for include) #16233

Merged
merged 2 commits into from
May 21, 2016

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented May 6, 2016

This fixes a bug I noticed in #16218, in which include("foo.jl\0") would erroneously succeed if "foo.jl" existed, because the filename would be silently truncated at the NUL char (similar to #10991).

I did an audit of the other functions in src/*.h, and I couldn't find any other problems of this kind.

@stevengj stevengj added bug Indicates an unexpected problem or unintended behavior backport pending 0.4 labels May 6, 2016
@@ -4,6 +4,8 @@ using Base.Test

@test @__LINE__ == 5

@test_throws ArgumentError include("test_sourcepath.jl\0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just call Core.include directly here? Otherwise, include_from_node1 is confusing the tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

@tkelman tkelman merged commit cac984e into JuliaLang:master May 21, 2016
@stevengj stevengj deleted the include_nul branch May 21, 2016 17:35
@@ -731,6 +731,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
Copy link
Contributor

@tkelman tkelman Jun 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On release-0.4, jl-parse-file is used inside jl_start_parsing_file which does not take the len as input. Could you propose a backported version, preferably w.r.t. tk/backports-0.4.6 if you want to get this in?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, these functions should not take a length argument since they really don't support anything other than NUL terminated strings....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump again, would need assistance to resolve the conflict if you want this on release-0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants