8000 proxy: Return an error for invalid proxy URLs instead of crashing. by lrm29 · Pull Request #6597 · libgit2/libgit2 · GitHub
[go: up one dir, main page]

Skip to content

proxy: Return an error for invalid proxy URLs instead of crashing. #6597

New issue

Have a question about this project? Sign up for a free GitHub account to open an 8000 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

Merged
merged 8 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/libgit2/transports/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,15 @@ static int lookup_proxy(
}

if (!proxy ||
(error = git_net_url_parse(&transport->proxy.url, proxy)) < 0)
(error = git_net_url_parse_http(&transport->proxy.url, proxy)) < 0)
goto done;

if (!git_net_url_valid(&transport->proxy.url)) {
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy);
error = -1;
goto done;
}

*out_use = true;

done:
Expand Down
5 changes: 5 additions & 0 deletions src/libgit2/transports/httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,11 @@ GIT_INLINE(int) server_setup_from_url(
git_http_server *server,
git_net_url *url)
{
GIT_ASSERT_ARG(url);
GIT_ASSERT_ARG(url->scheme);
GIT_ASSERT_ARG(url->host);
GIT_ASSERT_ARG(url->port);

if (!server->url.scheme || strcmp(server->url.scheme, url->scheme) ||
!server->url.host || strcmp(server->url.host, url->host) ||
!server->url.port || strcmp(server->url.port, url->port)) {
Expand Down
4 changes: 2 additions & 2 deletions src/libgit2/transports/winhttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,10 @@ static int winhttp_stream_connect(winhttp_stream *s)

git_net_url_dispose(&t->proxy.url);

if ((error = git_net_url_parse(&t->proxy.url, proxy_url)) < 0)
if ((error = git_net_url_parse_http(&t->proxy.url, proxy_url)) < 0)
goto on_error;

if (strcmp(t->proxy.url.scheme, "http") != 0 && strcmp(t->proxy.url.scheme, "https") != 0) {
if (!git_net_url_valid(&t->proxy.url)) {
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy_url);
error = -1;
goto on_error;
Expand Down
Loading
0