8000 Validate proxy URL on Windows. · libgit2/libgit2@5a13d4c · GitHub
[go: up one dir, main page]

Skip to content

Commit 5a13d4c

Browse files
lrm29ethomson
authored andcommitted
Validate proxy URL on Windows.
1 parent 402f63a commit 5a13d4c

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/libgit2/transports/http.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,13 @@ static int lookup_proxy(
334334
return 0;
335335
}
336336

337-
if (!proxy)
338-
goto done;
339-
340-
341-
if ((error = git_net_url_parse(&transport->proxy.url, proxy) < 0))
337+
if (!proxy ||
338+
(error = git_net_url_parse(&transport->proxy.url, proxy)) < 0)
342339
goto done;
343340

344341
if (!git_net_url_valid(&transport->proxy.url)) {
345-
git_error_set(GIT_ERROR_HTTP, "invalid proxy url: %s", proxy);
346-
error = GIT_EINVALIDSPEC;
342+
git_error_set(GIT_ERROR_HTTP, "invalid URL: '%s'", proxy);
343+
error = -1;
347344
goto done;
348345
}
349346

src/libgit2/transports/winhttp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
446446
if ((error = git_net_url_parse(&t->proxy.url, proxy_url)) < 0)
447447
goto on_error;
448448

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

tests/libgit2/online/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,10 @@ void test_online_clone__proxy_invalid_url(void)
975975
g_options.fetch_opts.proxy_opts.certificate_check = proxy_cert_cb;
976976

977977
g_options.fetch_opts.proxy_opts.url = "noschemeorport";
978-
cl_git_fail_with(GIT_EINVALIDSPEC, git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
978+
cl_git_fail(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
979979

980980
g_options.fetch_opts.proxy_opts.url = "noscheme:8080";
981-
cl_git_fail_with(GIT_EINVALIDSPEC, git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
981+
cl_git_fail(git_clone(&g_repo, "http://github.com/libgit2/TestGitRepository", "./foo", &g_options));
982982
}
983983

984984
void test_online_clone__proxy_credentials_request(void)

0 commit comments

Comments
 (0)
0