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
b7ffc63b
Commit
b7ffc63b
authored
Dec 17, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: handle ipv6 addresses
parent
2807de5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
+27
-15
src/transports/winhttp.c
+27
-15
No files found.
src/transports/winhttp.c
View file @
b7ffc63b
...
...
@@ -451,8 +451,14 @@ static int winhttp_stream_connect(winhttp_stream *s)
git_buf_puts
(
&
processed_url
,
t
->
proxy
.
url
.
scheme
);
git_buf_PUTS
(
&
processed_url
,
"://"
);
if
(
git_net_url_is_ipv6
(
&
t
->
proxy
.
url
))
git_buf_putc
(
&
processed_url
,
'['
);
git_buf_puts
(
&
processed_url
,
t
->
proxy
.
url
.
host
);
if
(
git_net_url_is_ipv6
(
&
t
->
proxy
.
url
))
git_buf_putc
(
&
processed_url
,
']'
);
if
(
!
git_net_url_is_default_port
(
&
t
->
proxy
.
url
))
git_buf_printf
(
&
processed_url
,
":%s"
,
t
->
proxy
.
url
.
port
);
...
...
@@ -736,10 +742,11 @@ static void CALLBACK winhttp_status(
static
int
winhttp_connect
(
winhttp_subtransport
*
t
)
{
wchar_t
*
wide_host
;
wchar_t
*
wide_host
=
NULL
;
int32_t
port
;
wchar_t
*
wide_ua
;
git_buf
ua
=
GIT_BUF_INIT
;
wchar_t
*
wide_ua
=
NULL
;
git_buf
ipv6
=
GIT_BUF_INIT
,
ua
=
GIT_BUF_INIT
;
const
char
*
host
;
int
error
=
-
1
;
int
default_timeout
=
TIMEOUT_INFINITE
;
int
default_connect_timeout
=
DEFAULT_CONNECT_TIMEOUT
;
...
...
@@ -755,29 +762,33 @@ static int winhttp_connect(
/* Prepare port */
if
(
git__strntol32
(
&
port
,
t
->
server
.
url
.
port
,
strlen
(
t
->
server
.
url
.
port
),
NULL
,
10
)
<
0
)
return
-
1
;
goto
on_error
;
/* IPv6? Add braces around the host. */
if
(
git_net_url_is_ipv6
(
&
t
->
server
.
url
))
{
if
(
git_buf_printf
(
&
ipv6
,
"[%s]"
,
t
->
server
.
url
.
host
)
<
0
)
goto
on_error
;
host
=
ipv6
.
ptr
;
}
else
{
host
=
t
->
server
.
url
.
host
;
}
/* Prepare host */
if
(
git__utf8_to_16_alloc
(
&
wide_host
,
t
->
server
.
url
.
host
)
<
0
)
{
if
(
git__utf8_to_16_alloc
(
&
wide_host
,
host
)
<
0
)
{
git_error_set
(
GIT_ERROR_OS
,
"unable to convert host to wide characters"
);
return
-
1
;
goto
on_error
;
}
if
((
error
=
git_http__user_agent
(
&
ua
))
<
0
)
{
git__free
(
wide_host
);
return
error
;
}
if
(
git_http__user_agent
(
&
ua
)
<
0
)
goto
on_error
;
if
(
git__utf8_to_16_alloc
(
&
wide_ua
,
git_buf_cstr
(
&
ua
))
<
0
)
{
git_error_set
(
GIT_ERROR_OS
,
"unable to convert host to wide characters"
);
git__free
(
wide_host
);
git_buf_dispose
(
&
ua
);
return
-
1
;
goto
on_error
;
}
git_buf_dispose
(
&
ua
);
/* Establish session */
t
->
session
=
WinHttpOpen
(
wide_ua
,
...
...
@@ -836,6 +847,7 @@ on_error:
if
(
error
<
0
)
winhttp_close_connection
(
t
);
git_buf_dispose
(
&
ipv6
);
git__free
(
wide_host
);
git__free
(
wide_ua
);
...
...
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