Skip to content

[SAST] Fix several potential null dereference cases#2765

Open
Canned-pineapple-8 wants to merge 3 commits into
unbit:masterfrom
Canned-pineapple-8:fix/null-dereferences-issue-2755
Open

[SAST] Fix several potential null dereference cases#2765
Canned-pineapple-8 wants to merge 3 commits into
unbit:masterfrom
Canned-pineapple-8:fix/null-dereferences-issue-2755

Conversation

@Canned-pineapple-8

Copy link
Copy Markdown

Fixes 3 potential null dereference issues found by Svace static analyzer.

Commits

  1. fix(websockets): check ub for NULL before uwsgi_buffer_destroy()
  2. fix(exceptions): add NULL check for exception_msg before dereference
  3. fix(xmlconf): check strdup() success in textElement() and endElement()

Notes

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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SAST] Several potential null dereference cases

1 participant