[SAST] Fix several potential null dereference cases#2765
Open
Canned-pineapple-8 wants to merge 3 commits into
Open
[SAST] Fix several potential null dereference cases#2765Canned-pineapple-8 wants to merge 3 commits into
Canned-pineapple-8 wants to merge 3 commits into
Conversation
In uwsgi_websockets_parse(), variable 'ub' is initialized to NULL. If the buffer is empty, the code jumps to the 'error' label where uwsgi_buffer_destroy(ub) is called unconditionally, causing a null dereference. Add a NULL check before destroying the buffer. Fixes null dereference found by Svace static analyzer
In uwsgi_manage_exception(), uwsgi.p[...]->exception_msg is checked for NULL earlier, but then dereferenced later without a check. Add the missing NULL check to the condition before accessing it. Fixes null dereference found by Svace static analyzer
strdup() may fail under OOM conditions, returning NULL. Passing NULL to add_exported_option() would cause a null dereference. Add NULL checks for both strdup() calls. Fixes null dereference found by Svace static analyzer
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.
Fixes 3 potential null dereference issues found by Svace static analyzer.
Commits
fix(websockets): check ub for NULL before uwsgi_buffer_destroy()fix(exceptions): add NULL check for exception_msg before dereferencefix(xmlconf): check strdup() success in textElement() and endElement()Notes
exceptions.crequires clarification from maintainers (see issue [SAST] Several potential null dereference cases #2755). The proposed fix adds a NULL check without changing logic (hopefully)Closes #2755
If any fix is incorrect, please comment on the specific commit or reference the problem number from the issue. I will update the PR accordingly.