Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
402f63a4
Commit
402f63a4
authored
Jul 17, 2023
by
lmcglash
Committed by
Edward Thomson
Aug 02, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return an error for invalid proxy URLs instead of crashing.
parent
0ddc0776
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
src/libgit2/transports/http.c
+11
-2
tests/libgit2/online/clone.c
+13
-0
No files found.
src/libgit2/transports/http.c
View file @
402f63a4
...
@@ -334,10 +334,19 @@ static int lookup_proxy(
...
@@ -334,10 +334,19 @@ static int lookup_proxy(
return
0
;
return
0
;
}
}
if
(
!
proxy
||
if
(
!
proxy
)
(
error
=
git_net_url_parse
(
&
transport
->
proxy
.
url
,
proxy
))
<
0
)
goto
done
;
goto
done
;
if
((
error
=
git_net_url_parse
(
&
transport
->
proxy
.
url
,
proxy
)
<
0
))
goto
done
;
if
(
!
git_net_url_valid
(
&
transport
->
proxy
.
url
))
{
git_error_set
(
GIT_ERROR_HTTP
,
"invalid proxy url: %s"
,
proxy
);
error
=
GIT_EINVALIDSPEC
;
goto
done
;
}
*
out_use
=
true
;
*
out_use
=
true
;
done
:
done
:
...
...
tests/libgit2/online/clone.c
View file @
402f63a4
...
@@ -968,6 +968,19 @@ static int proxy_cert_cb(git_cert *cert, int valid, const char *host, void *payl
...
@@ -968,6 +968,19 @@ static int proxy_cert_cb(git_cert *cert, int valid, const char *host, void *payl
return
valid
?
0
:
GIT_ECERTIFICATE
;
return
valid
?
0
:
GIT_ECERTIFICATE
;
}
}
void
test_online_clone__proxy_invalid_url
(
void
)
{
g_options
.
fetch_opts
.
proxy_opts
.
type
=
GIT_PROXY_SPECIFIED
;
g_options
.
fetch_opts
.
proxy_opts
.
credentials
=
proxy_cred_cb
;
g_options
.
fetch_opts
.
proxy_opts
.
certificate_check
=
proxy_cert_cb
;
g_options
.
fetch_opts
.
proxy_opts
.
url
=
"noschemeorport"
;
cl_git_fail_with
(
GIT_EINVALIDSPEC
,
git_clone
(
&
g_repo
,
"http://github.com/libgit2/TestGitRepository"
,
"./foo"
,
&
g_options
));
g_options
.
fetch_opts
.
proxy_opts
.
url
=
"noscheme:8080"
;
cl_git_fail_with
(
GIT_EINVALIDSPEC
,
git_clone
(
&
g_repo
,
"http://github.com/libgit2/TestGitRepository"
,
"./foo"
,
&
g_options
));
}
void
test_online_clone__proxy_credentials_request
(
void
)
void
test_online_clone__proxy_credentials_request
(
void
)
{
{
git_str
url
=
GIT_STR_INIT
;
git_str
url
=
GIT_STR_INIT
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment