mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
sys_net: getsockname on unbound p2p socket fix
This commit is contained in:
parent
0e625e193e
commit
683c061e60
@ -1903,7 +1903,7 @@ error_code sys_net_bnet_getsockname(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sock
|
||||
return -SYS_NET_EINVAL;
|
||||
}
|
||||
|
||||
::sockaddr_storage native_addr;
|
||||
::sockaddr_storage native_addr{};
|
||||
::socklen_t native_addrlen = sizeof(native_addr);
|
||||
|
||||
lv2_socket_type type;
|
||||
@ -1916,6 +1916,12 @@ error_code sys_net_bnet_getsockname(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sock
|
||||
type = sock.type;
|
||||
p2p_vport = sock.p2p.vport;
|
||||
|
||||
// Unbound P2P socket special case
|
||||
if ((sock.type == SYS_NET_SOCK_DGRAM_P2P || sock.type == SYS_NET_SOCK_STREAM_P2P) && sock.socket == 0)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (::getsockname(sock.socket, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen) == 0)
|
||||
{
|
||||
ensure(native_addr.ss_family == AF_INET);
|
||||
@ -1928,8 +1934,6 @@ error_code sys_net_bnet_getsockname(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sock
|
||||
// windows doesn't support getsockname for sockets that are not bound
|
||||
if (get_native_error() == WSAEINVAL)
|
||||
{
|
||||
memset(&native_addr, 0, native_addrlen);
|
||||
native_addr.ss_family = AF_INET;
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user