Fix minor time-of-check vs time-of-use pointer issues#40128
Closed
kokke wants to merge 2 commits intonodejs:masterfrom
Closed
Fix minor time-of-check vs time-of-use pointer issues#40128kokke wants to merge 2 commits intonodejs:masterfrom
kokke wants to merge 2 commits intonodejs:masterfrom
Conversation
kokke
added a commit
to kokke/node
that referenced
this pull request
Sep 15, 2021
kokke
added a commit
to kokke/node
that referenced
this pull request
Sep 15, 2021
Contributor
Author
|
Aw, the asan-test failed because of a timeout :( Can it be re-run without me doing a new push? |
addaleax
reviewed
Sep 16, 2021
Member
|
@kokke would you like to update the PR? |
Contributor
Author
|
Hi @targos - sorry for keeping you guys waiting! I assumed whomever approved the PR, would incorporate the changes proposed by @addaleax I have pushed those to my fork now, so I think the PR is ready to be merged (once tests complete). Please let me know if I have misunderstood or need to do anything else to satisfy the process. |
addaleax
approved these changes
Sep 27, 2021
Contributor
Author
|
@targos I've updated the PR - thanks for your patience with me :) |
Collaborator
jasnell
approved these changes
Sep 30, 2021
Contributor
|
Landed in afb4ad6...4f3eda6 |
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.
This PR addresses two minor issues (nits):
1 : A time-of-use/time-of-check 'bug' in src/crypto/crypto_context.cc
The pointer 'env' is checked against NULL on line 1117, but it gets dereferenced at line 1101+1102.
Note comments for line 1101, 1102 and 1117.
Suggestion: Skip the null-check on line 1117. If 'env' could be NULL, the code would have segfaulted before reaching line 1117 anyway.
and 2 : A time-of-check vs time-of-use bug in src/udp_wrap.cc:370
The pointer 'wrap' is checked against NULL on line 376, but it gets dereferenced at line 370.
Note comments for line 370 and 376.
Suggested solutions:
So the code becomes either:
... or
For context: These two issues were found using a homemade static analysis tool that flags instances where pointers are checked against NULL after they have already been dereferenced.