Fix: memory leak in auth_create_digest_http_message() in lib/vauth/digest.c#20862
Conversation
|
This causes double-free of that pointer in the other branches now. |
|
Analysis of PR #20862 at 84f0c771: Test ../../tests/http/test_17_ssl_use.py::TestSSLUse::test_17_09_ssl_min_max[TLSv1.3-none-none] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_17_ssl_use.py::TestSSLUse::test_17_09_ssl_min_max[TLSv1.3-none-1.2] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_17_ssl_use.py::TestSSLUse::test_17_09_ssl_min_max[TLSv1.3-none-1.3] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_17_ssl_use.py::TestSSLUse::test_17_09_ssl_min_max[TLSv1.3-tlsv1-none] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_17_ssl_use.py::TestSSLUse::test_17_09_ssl_min_max[TLSv1.3-tlsv1-1.2] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_17_ssl_use.py::TestSSLUse::test_17_09_ssl_min_max[TLSv1.3-tlsv1-1.3] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). Test ../../tests/http/test_17_ssl_use.py::TestSSLUse::test_17_09_ssl_min_max[TLSv1.3-tlsv1.0-none] failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them). There are more failures, but that's enough from Gha. Generated by Testclutch |
…gest.c Signed-off-by: huanghuihui0904 <625173@qq.com>
84f0c77 to
c569449
Compare
Good catch, thanks! I've updated the fix to avoid that and pushed a new commit. |
There was a problem hiding this comment.
Pull request overview
Fixes a potential memory leak in auth_create_digest_http_message() (lib/vauth/digest.c) when the auth-int branch hits an early error and jumps to oom:.
Changes:
- Free
hashthisbeforegoto oomwhenhash()fails in theauth-intpath.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
Thanks! |
Bug description
While reviewing
auth_create_digest_http_message()inlib/vauth/digest.c, I noticed an error path that may leak the heap-allocated bufferhashthis.hashthisis allocated here (line 800):In the
auth-intbranch, if the subsequenthash()call fails, execution jumps tooom:without freeinghashthis(line 806–813):However, the cleanup block does not free
hashthis(line 953–960):As a result, if the
hash()call fails in theauth-intbranch afterhashthishas been allocated, the function jumps tooom:and returns without freeinghashthis, which may lead to a memory leak.Fix
Free
hashthisbefore jumping tooom:whenhash()fails. The fix is included in the commit.