urlapi: fix memleaks on error in parse_hostname_login()#21879
Closed
vszakats wants to merge 4 commits into
Closed
Conversation
Member
|
It would be ideal to also get a test case that reproduces this leak... |
parse_hostname_login()parse_hostname_login()
Detected by GitHub Code Quality Ref: acd82c8 curl#11006 Ref: 4183b8f curl#8049
There was a problem hiding this comment.
Pull request overview
This PR addresses a potential memory leak in parse_hostname_login() within curl’s URL parsing code by ensuring already-set credential fields are freed on error paths, and adds a unit test to cover the behavior.
Changes:
- Update
parse_hostname_login()error handling to freeu->user,u->password, andu->options(preventing leaks when those fields were previously allocated). - Expose
parse_hostname_login()under the existingUNITTESTmechanism and annotate it for unit testing. - Add unit coverage in
unit1675for login parsing outcomes (including scheme-dependent;optionsparsing andCURLU_DISALLOW_USER).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/urlapi.c | Frees existing credential fields on parse_hostname_login() error paths; makes function available for unit tests. |
| tests/unit/unit1675.c | Adds unit tests exercising parse_hostname_login() credential parsing and error behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
parse_hostname_login()parse_hostname_login()
dkarpov1970
pushed a commit
to dkarpov1970/curl
that referenced
this pull request
Jun 9, 2026
Detected by GitHub Code Quality Follow-up to acd82c8 curl#11006 Follow-up to 4183b8f curl#8049 Closes curl#21879
dkarpov1970
pushed a commit
to dkarpov1970/curl
that referenced
this pull request
Jun 10, 2026
Detected by GitHub Code Quality Follow-up to acd82c8 curl#11006 Follow-up to 4183b8f curl#8049 Closes curl#21879
5 tasks
vszakats
added a commit
that referenced
this pull request
Jun 10, 2026
Adjust code to avoid `-Wformat-signedness` warnings, while making sure that enums are always cast to a known type when passing them to `printf` functions, to support compilers and compiler settings where enums are not default-size signed ints. - cast integers printed as hex to `unsigned`. (63 times, 20 of them in `mbedtls.c`) - cast misc enums to `int` for printing. (31 times) - cast `CURL_LOCK_DATA_*` enums to `int`. (4 times) - cast `CURL_FORMADD_*` enums to `int`. (13 times) - cast `CURLSHE_*` enums to `int`. (3 times) - cast `CURLUE_*` enums to `int`. (33 times) - cast `CURLMSG_*` enums to `int`. (6 times) - cast `CURLE_*` enums to `int`. (~380 times) - unit1675: fix mask. Follow-up to 7c34365 #21879 Ref: #18343 (initial attempt) Closes #20848
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.
Detected by GitHub Code Quality
Follow-up to acd82c8 #11006
Follow-up to 4183b8f #8049