node-api: avoid crashing on passed-in null string#38923
Closed
gabrielschulhof wants to merge 2 commits intonodejs:masterfrom
Closed
node-api: avoid crashing on passed-in null string#38923gabrielschulhof wants to merge 2 commits intonodejs:masterfrom
gabrielschulhof wants to merge 2 commits intonodejs:masterfrom
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 <gabrielschulhof@gmail.com>
e86316d to
b5dc717
Compare
bl-ue
approved these changes
Jun 4, 2021
addaleax
requested changes
Jun 5, 2021
Member
addaleax
left a comment
There was a problem hiding this comment.
str should be allowed to be nullptr if length is 0.
Contributor
Author
|
@addaleax I added an allowance for NULL when the length given is zero. PTAL! |
addaleax
approved these changes
Jun 7, 2021
legendecas
approved these changes
Jun 7, 2021
Collaborator
jasnell
reviewed
Jun 7, 2021
| napi_value* result) { | ||
| CHECK_ENV(env); | ||
| if (length > 0) | ||
| CHECK_ARG(env, str); |
Member
There was a problem hiding this comment.
The naming of these macros is really unfortunate. Everywhere else, CHECK_* generally implies an assert.
jasnell
approved these changes
Jun 7, 2021
fhinkel
approved these changes
Jun 8, 2021
Member
|
Resume attemp: https://ci.nodejs.org/job/node-test-pull-request/38563/ |
Collaborator
gabrielschulhof
added a commit
that referenced
this pull request
Jun 11, 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 <gabrielschulhof@gmail.com> PR-URL: #38923 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Contributor
Author
|
Landed in d615aeb. |
danielleadams
pushed a commit
that referenced
this pull request
Jun 13, 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 <gabrielschulhof@gmail.com> PR-URL: #38923 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Merged
danielleadams
pushed a commit
that referenced
this pull request
Jun 17, 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 <gabrielschulhof@gmail.com> PR-URL: #38923 Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Member
|
This is blocked from landing on v14.x-staging as it depends on #37217. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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