-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
src: fix array overrun in node::url::SetArgs() #46541
Conversation
Fast-track has been requested by @tniessen. Please 👍 to approve. |
@@ -47,7 +47,7 @@ enum url_update_action { | |||
kHref = 9, | |||
}; | |||
|
|||
void SetArgs(Environment* env, Local<Value> argv[12], const ada::result& url) { | |||
void SetArgs(Environment* env, Local<Value> argv[13], const ada::result& url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array arguments decay to pointers so this, in the abstract, doesn't fix anything. You could change it to:
void SetArgs(Environment* env, Local<Value> argv[13], const ada::result& url) { | |
void SetArgs(Environment* env, Local<Value> (*argv)[13], const ada::result& url) { |
That forces callers to pass a 13-element array by address, i.e.:
Local<Value> argv[13];
SetArgs(env, &argv, url);
You'll need to update all the assignments from argv[0]
to (*argv)[0]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For education purposes: How did the code work before this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wrote past the end. Array arguments aren't length-checked; to the compiler int x[42]
equals int x[]
equals int *x
.
cc @nodejs/url |
Seems like #46736 implicitly overwrote this. |
I believe @bnoordhuis's comment above is still relevant though. @anonrig is there any chance you could pick it up in a future PR? |
I agree. I'll open a PR. Thanks for the mention. |
Refs: #46410