Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
715e6b6b
Commit
715e6b6b
authored
Sep 18, 2017
by
Kenton Varda
Committed by
GitHub
Sep 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #556 from capnproto/capability-stream
Make win32Socketpair() more secure
parents
8851c85d
9a9fd5f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
async-io-win32.c++
c++/src/kj/async-io-win32.c++
+19
-0
No files found.
c++/src/kj/async-io-win32.c++
View file @
715e6b6b
...
...
@@ -149,10 +149,29 @@ int win32Socketpair(SOCKET socks[2]) {
if
(
connect
(
socks
[
0
],
&
a
.
addr
,
sizeof
(
a
.
inaddr
))
==
SOCKET_ERROR
)
break
;
retryAccept:
socks
[
1
]
=
accept
(
listener
,
NULL
,
NULL
);
if
(
socks
[
1
]
==
-
1
)
break
;
// Verify that the client is actually us and not someone else who raced to connect first.
// (This check added by Kenton for security.)
union
{
struct
sockaddr_in
inaddr
;
struct
sockaddr
addr
;
}
b
,
c
;
socklen_t
bAddrlen
=
sizeof
(
b
.
inaddr
);
socklen_t
cAddrlen
=
sizeof
(
b
.
inaddr
);
if
(
getpeername
(
socks
[
1
],
&
b
.
addr
,
&
bAddrlen
)
==
SOCKET_ERROR
)
break
;
if
(
getsockname
(
socks
[
0
],
&
c
.
addr
,
&
cAddrlen
)
==
SOCKET_ERROR
)
break
;
if
(
bAddrlen
!=
cAddrlen
||
memcmp
(
&
b
.
addr
,
&
c
.
addr
,
bAddrlen
)
!=
0
)
{
// Someone raced to connect first. Ignore.
closesocket
(
socks
[
1
]);
goto
retryAccept
;
}
closesocket
(
listener
);
return
0
;
}
...
...
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