Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
node-api: avoid crashing on passed-in null string#38923
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
node-api: avoid crashing on passed-in null string #38923
Uh oh!
There was an error while loading. Please reload this page.
Conversation
When `napi_create_string_*` receives a null pointer as its second argument, it must null-check it before passing it into V8, otherwise a crash will occur. Signed-off-by: Gabriel Schulhof <[email protected]>
e86316d to b5dc717Compare
mhdawson left a comment
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.
LGTM
addaleax left a comment
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.
str should be allowed to be nullptr if length is 0.
gabrielschulhof commented Jun 7, 2021
@addaleax I added an allowance for NULL when the length given is zero. PTAL! |
nodejs-github-bot commented Jun 7, 2021
| napi_value* result){ | ||
| CHECK_ENV(env); | ||
| if (length > 0) | ||
| CHECK_ARG(env, str); |
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.
The naming of these macros is really unfortunate. Everywhere else, CHECK_* generally implies an assert.
mhdawson commented Jun 10, 2021
Resume attemp: https://ci.nodejs.org/job/node-test-pull-request/38563/ |
nodejs-github-bot commented Jun 10, 2021
When `napi_create_string_*` receives a null pointer as its second argument, it must null-check it before passing it into V8, otherwise a crash will occur. Signed-off-by: Gabriel Schulhof <[email protected]> PR-URL: #38923 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
gabrielschulhof commented Jun 11, 2021
Landed in d615aeb. |
When `napi_create_string_*` receives a null pointer as its second argument, it must null-check it before passing it into V8, otherwise a crash will occur. Signed-off-by: Gabriel Schulhof <[email protected]> PR-URL: #38923 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
When `napi_create_string_*` receives a null pointer as its second argument, it must null-check it before passing it into V8, otherwise a crash will occur. Signed-off-by: Gabriel Schulhof <[email protected]> PR-URL: #38923 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
richardlau commented Jul 19, 2021
This is blocked from landing on v14.x-staging as it depends on #37217. |
When
napi_create_string_*receives a null pointer as its secondargument, it must null-check it before passing it into V8, otherwise a
crash will occur.
Signed-off-by: @gabrielschulhof