Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
72c1cf59
Commit
72c1cf59
authored
Feb 22, 2019
by
Hans Leidekker
Committed by
Alexandre Julliard
Feb 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ws2_32: Always set overlapped status in AcceptEx.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ba147731
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
socket.c
dlls/ws2_32/socket.c
+5
-4
sock.c
dlls/ws2_32/tests/sock.c
+30
-0
No files found.
dlls/ws2_32/socket.c
View file @
72c1cf59
...
...
@@ -2822,15 +2822,16 @@ static BOOL WINAPI WS2_AcceptEx(SOCKET listener, SOCKET acceptor, PVOID dest, DW
TRACE
(
"(%04lx, %04lx, %p, %d, %d, %d, %p, %p)
\n
"
,
listener
,
acceptor
,
dest
,
dest_len
,
local_addr_len
,
rem_addr_len
,
received
,
overlapped
);
if
(
!
dest
)
if
(
!
overlapped
)
{
SetLastError
(
WSA
EINVAL
);
SetLastError
(
WSA
_INVALID_PARAMETER
);
return
FALSE
;
}
overlapped
->
Internal
=
STATUS_PENDING
;
if
(
!
overlapped
)
if
(
!
dest
)
{
SetLastError
(
WSA
_INVALID_PARAMETER
);
SetLastError
(
WSA
EINVAL
);
return
FALSE
;
}
...
...
dlls/ws2_32/tests/sock.c
View file @
72c1cf59
...
...
@@ -8276,18 +8276,22 @@ static void test_AcceptEx(void)
goto
end
;
}
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
INVALID_SOCKET
,
acceptor
,
buffer
,
sizeof
(
buffer
)
-
2
*
(
sizeof
(
struct
sockaddr_in
)
+
16
),
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
WSAENOTSOCK
,
"AcceptEx on invalid listening socket "
"returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
sizeof
(
buffer
)
-
2
*
(
sizeof
(
struct
sockaddr_in
)
+
16
),
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
todo_wine
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
WSAEINVAL
,
"AcceptEx on a non-listening socket "
"returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
iret
=
listen
(
listener
,
5
);
if
(
iret
!=
0
)
{
...
...
@@ -8295,43 +8299,55 @@ todo_wine
goto
end
;
}
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
INVALID_SOCKET
,
buffer
,
sizeof
(
buffer
)
-
2
*
(
sizeof
(
struct
sockaddr_in
)
+
16
),
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
WSAENOTSOCK
,
"AcceptEx on invalid accepting socket "
"returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
NULL
,
sizeof
(
buffer
)
-
2
*
(
sizeof
(
struct
sockaddr_in
)
+
16
),
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
todo_wine
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
WSAEFAULT
,
"AcceptEx on NULL buffer returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
0
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
,
"AcceptEx on too small local address size returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
bret
=
CancelIo
((
HANDLE
)
listener
);
ok
(
bret
,
"Failed to cancel pending accept socket
\n
"
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
sizeof
(
struct
sockaddr_in
)
+
15
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
,
"AcceptEx on too small local address "
"size returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
bret
=
CancelIo
((
HANDLE
)
listener
);
ok
(
bret
,
"Failed to cancel pending accept socket
\n
"
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
sizeof
(
struct
sockaddr_in
)
+
16
,
0
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
WSAEFAULT
,
"AcceptEx on too small remote address size returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
15
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
,
"AcceptEx on too small remote address size returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
bret
=
CancelIo
((
HANDLE
)
listener
);
ok
(
bret
,
"Failed to cancel pending accept socket
\n
"
);
...
...
@@ -8351,16 +8367,20 @@ todo_wine
goto
end
;
}
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
,
"AcceptEx returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
todo_wine
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
WSAEINVAL
,
"AcceptEx on already pending socket returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
if
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
)
{
/* We need to cancel this call, otherwise things fail */
bret
=
CancelIo
((
HANDLE
)
listener
);
...
...
@@ -8368,10 +8388,12 @@ todo_wine
if
(
!
bret
)
return
;
WaitForSingleObject
(
overlapped
.
hEvent
,
0
);
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
,
"AcceptEx returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
}
iret
=
connect
(
acceptor
,
(
struct
sockaddr
*
)
&
bindAddress
,
sizeof
(
bindAddress
));
...
...
@@ -8390,17 +8412,21 @@ todo_wine
ok
(
bret
,
"Failed to cancel failed test. Bailing...
\n
"
);
if
(
!
bret
)
return
;
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
0
,
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
,
"AcceptEx returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
}
overlapped
.
Internal
=
0xdeadbeef
;
iret
=
connect
(
connector
,
(
struct
sockaddr
*
)
&
bindAddress
,
sizeof
(
bindAddress
));
ok
(
iret
==
0
,
"connecting to accepting socket failed, error %d
\n
"
,
WSAGetLastError
());
dwret
=
WaitForSingleObject
(
overlapped
.
hEvent
,
INFINITE
);
ok
(
dwret
==
WAIT_OBJECT_0
,
"Waiting for accept event failed with %d + errno %d
\n
"
,
dwret
,
GetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_SUCCESS
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
bret
=
GetOverlappedResult
((
HANDLE
)
listener
,
&
overlapped
,
&
bytesReturned
,
FALSE
);
ok
(
bret
,
"GetOverlappedResult failed, error %d
\n
"
,
GetLastError
());
...
...
@@ -8422,10 +8448,12 @@ todo_wine
skip
(
"could not create connector socket, error %d
\n
"
,
WSAGetLastError
());
goto
end
;
}
overlapped
.
Internal
=
0xdeadbeef
;
bret
=
pAcceptEx
(
listener
,
acceptor
,
buffer
,
2
,
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
&
bytesReturned
,
&
overlapped
);
ok
(
bret
==
FALSE
&&
WSAGetLastError
()
==
ERROR_IO_PENDING
,
"AcceptEx returned %d + errno %d
\n
"
,
bret
,
WSAGetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
connect_time
=
0xdeadbeef
;
optlen
=
sizeof
(
connect_time
);
...
...
@@ -8445,6 +8473,7 @@ todo_wine
dwret
=
WaitForSingleObject
(
overlapped
.
hEvent
,
0
);
ok
(
dwret
==
WAIT_TIMEOUT
,
"Waiting for accept event timeout failed with %d + errno %d
\n
"
,
dwret
,
GetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_PENDING
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
iret
=
getsockname
(
connector
,
(
struct
sockaddr
*
)
&
peerAddress
,
&
remoteSize
);
ok
(
!
iret
,
"getsockname failed.
\n
"
);
...
...
@@ -8455,6 +8484,7 @@ todo_wine
dwret
=
WaitForSingleObject
(
overlapped
.
hEvent
,
1000
);
ok
(
dwret
==
WAIT_OBJECT_0
,
"Waiting for accept event failed with %d + errno %d
\n
"
,
dwret
,
GetLastError
());
ok
(
overlapped
.
Internal
==
STATUS_SUCCESS
,
"got %08x
\n
"
,
(
ULONG
)
overlapped
.
Internal
);
/* Check if the buffer from AcceptEx is decoded correctly */
pGetAcceptExSockaddrs
(
buffer
,
2
,
sizeof
(
struct
sockaddr_in
)
+
16
,
sizeof
(
struct
sockaddr_in
)
+
16
,
...
...
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