8000 Fix null pointer dereference in function MdnsAvahi::Resolve by mugitya03 · Pull Request #39844 · project-chip/connectedhomeip · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix null pointer dereference in function MdnsAvahi::Resolve #39844

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mugitya03
Copy link

Summary

The function AllocateResolveContext returns a null pointer if fails to create a new object. The NULL value potentially returned by AllocateResolveContext() is dereferenced without a null check, causing a null pointer dereference bug.

Testing

Verified using static analysis and manual review:

  • Identified the issue with a static analyzer and confirmed it through code inspection.
  • Applied this patch and re-ran the analysis, confirming that the bug report no longer appears.

The function AllocateResolveContext returns a null pointer if fails to create a new object.
The NULL value potentially returned by AllocateResolveContext() is dereferenced without a null check, causing a null pointer dereference bug.
Copy link
Contributor
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly identifies and fixes a critical null pointer dereference in MdnsAvahi::Resolve by adding a null check for the context returned by AllocateResolveContext. The fix is sound and prevents a potential crash. I've added one suggestion to use a project-specific helper macro to make the error handling more concise and consistent with what appears to be a common pattern in the codebase.

@andy31415
Copy link
Contributor

@mugitya03 please apply the restyle update to make restyler happy:

{ base64 -d - | git am; } <<'EOM'
RnJvbSBkZGIzOGJkNmRlOTlkOGQ0YjEyYWNjZmIxM2IwNmQ5MzFmNWI4ZGUzIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiAiUmVzdHlsZWQuaW8iIDxjb21taXRzQHJlc3R5bGVkLmlvPgpE
YXRlOiBUaHUsIDMgSnVsIDIwMjUgMTk6MjM6MzQgKzAwMDAKU3ViamVjdDogW1BBVENIXSBSZXN0
eWxlZCBieSBjbGFuZy1mb3J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AgcmVzb2x2ZUNvbnRleHQtPm1DYWxsYmFjayA9IGNhbGxi
YWNrOworICAgIHJlc29sdmVDb250ZXh0LT5tQ29udGV4dCAgPSBjb250ZXh0OwogCiAgICAgaWYg
KCFpbnRlcmZhY2UuSXNQcmVzZW50KCkpCiAgICAgewotLSAKMi40OS4wCg==
EOM

@mugitya03
Copy link
Author

@andy31415 Applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0