ws2_32: Always return the source address from WSAAccept.
This commit is contained in:
parent
260119e682
commit
1422a56667
|
@ -6555,7 +6555,7 @@ SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, LPINT addrlen,
|
|||
LPCONDITIONPROC lpfnCondition, DWORD_PTR dwCallbackData)
|
||||
{
|
||||
|
||||
int ret = 0, size = 0;
|
||||
int ret = 0, size;
|
||||
WSABUF CallerId, CallerData, CalleeId, CalleeData;
|
||||
/* QOS SQOS, GQOS; */
|
||||
GROUP g;
|
||||
|
@ -6565,34 +6565,37 @@ SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, LPINT addrlen,
|
|||
TRACE("Socket %04lx, sockaddr %p, addrlen %p, fnCondition %p, dwCallbackData %ld\n",
|
||||
s, addr, addrlen, lpfnCondition, dwCallbackData);
|
||||
|
||||
|
||||
size = sizeof(src_addr);
|
||||
cs = WS_accept(s, &src_addr, &size);
|
||||
|
||||
cs = WS_accept(s, addr, addrlen);
|
||||
if (cs == SOCKET_ERROR) return SOCKET_ERROR;
|
||||
|
||||
if (!lpfnCondition) return cs;
|
||||
|
||||
CallerId.buf = (char *)&src_addr;
|
||||
CallerId.len = sizeof(src_addr);
|
||||
|
||||
if (addr && addrlen)
|
||||
{
|
||||
CallerId.buf = (char *)addr;
|
||||
CallerId.len = *addrlen;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = sizeof(src_addr);
|
||||
WS_getpeername(cs, &src_addr, &size);
|
||||
CallerId.buf = (char *)&src_addr;
|
||||
CallerId.len = size;
|
||||
}
|
||||
CallerData.buf = NULL;
|
||||
CallerData.len = 0;
|
||||
|
||||
size = sizeof(dst_addr);
|
||||
WS_getsockname(cs, &dst_addr, &size);
|
||||
|
||||
CalleeId.buf = (char *)&dst_addr;
|
||||
CalleeId.len = sizeof(dst_addr);
|
||||
|
||||
|
||||
ret = (*lpfnCondition)(&CallerId, &CallerData, NULL, NULL,
|
||||
&CalleeId, &CalleeData, &g, dwCallbackData);
|
||||
|
||||
switch (ret)
|
||||
{
|
||||
case CF_ACCEPT:
|
||||
if (addr && addrlen)
|
||||
memcpy(addr, &src_addr, (*addrlen > size) ? size : *addrlen );
|
||||
return cs;
|
||||
case CF_DEFER:
|
||||
SERVER_START_REQ( set_socket_deferred )
|
||||
|
|
|
@ -3246,7 +3246,7 @@ static void test_accept(void)
|
|||
|
||||
socklen = 0;
|
||||
accepted = WSAAccept(server_socket, (struct sockaddr *)&ss, &socklen, NULL, 0);
|
||||
todo_wine ok(accepted == INVALID_SOCKET && WSAGetLastError() == WSAEFAULT, "got %d\n", WSAGetLastError());
|
||||
ok(accepted == INVALID_SOCKET && WSAGetLastError() == WSAEFAULT, "got %d\n", WSAGetLastError());
|
||||
ok(!socklen, "got %d\n", socklen);
|
||||
closesocket(connector);
|
||||
connector = INVALID_SOCKET;
|
||||
|
@ -3269,8 +3269,8 @@ static void test_accept(void)
|
|||
memset(&ss, 0, sizeof(ss));
|
||||
accepted = WSAAccept(server_socket, (struct sockaddr *)&ss, &socklen, NULL, 0);
|
||||
ok(accepted != INVALID_SOCKET, "Failed to accept connection, %d\n", WSAGetLastError());
|
||||
todo_wine ok(socklen != sizeof(ss), "unexpected length\n");
|
||||
todo_wine ok(ss.ss_family, "family not set\n");
|
||||
ok(socklen != sizeof(ss), "unexpected length\n");
|
||||
ok(ss.ss_family, "family not set\n");
|
||||
closesocket(accepted);
|
||||
closesocket(connector);
|
||||
accepted = connector = INVALID_SOCKET;
|
||||
|
|
Loading…
Reference in New Issue