Repository navigation
fix(http): pass no flags to curl_url_set in url_get_host - #6233
Open
Dev-next-gen wants to merge 1 commit into
Open
Dev-next-gen wants to merge 1 commit into
Dev-next-gen wants to merge 1 commit into
Conversation
The fourth argument of curl_url_set is a flags bitmask, but url_get_host passed the URL length. Whether a URL parsed therefore depended on its length: a schemeless URL was accepted only when the length set CURLU_DEFAULT_SCHEME, and a URL with user info was rejected whenever the length set CURLU_DISALLOW_USER.
Contributor
Author
|
|
This branch has not been deployed
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.



Description
http::url_get_hostcallscurl_url_set(curlu, CURLUPART_URL, url.c_str(), url.length()). The fourth argument ofcurl_url_setis a flags bitmask, not a length, so the bits of the URL length are read asCURLU_*flags and the parse result depends on how long the URL is.With libcurl 7.88.1:
https://[email protected]/a.pngCURLU_DISALLOW_USER""images.igdb.comhttps://[email protected]/ab.pngCURLU_DISALLOW_USER""images.igdb.comimages.igdb.com/a.pngCURLU_DEFAULT_SCHEMEimages.igdb.com""images.igdb.com/abcd.png""""/api/covers/uploaduses this function to allow onlyimages.igdb.com, so whether a cover URL is accepted depended on its length. The fix passes0, so every URL is parsed with libcurl's default rules: a URL without a scheme is always rejected, and user info no longer makes a valid URL fail. Fullhttps://images.igdb.com/...URLs, which is what the Web UI sends, return the same host as before.Screenshot
Issues Fixed or Closed
Roadmap Issues
Testing
Added three cases to
UrlGetHostTestsintests/unit/test_httpcommon.cpp: the user info URL and the two schemeless URLs from the table. On master the first two fail.I could not build
test_sunshinehere, so the gtest was not run locally; CI will run it. The table above comes fromurl_get_hostcopied unchanged fromsrc/httpcommon.cppon master and on this branch, compiled against libcurl 7.88.1 and called on those inputs. The existing cases (https://images.igdb.com/example.txt,http://localhost:8080,nonsense!!}{::) give the same result on both.Type of Change
Checklist
AI Usage
See our AI usage policy.
Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.5.