mirror of
https://git.citron-emu.org/citron/emulator
synced 2026-01-10 11:44:19 +00:00
fix(network): prevent datagram socket SendTo errors in HDR multiplayer
Changes: - Add validation in BSD::SendToImpl to check for empty address buffers on datagram sockets and return EINVAL instead of passing nullptr to sendto() - Add null pointer check in ProxySocket::SendTo to prevent dereferencing nullptr address parameters - Improve error logging to help identify socket configuration issues Fixes: Socket operation errors in HDR multiplayer sessions Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -889,6 +889,14 @@ std::pair<s32, Errno> BSD::SendToImpl(s32 fd, u32 flags, std::span<const u8> mes
|
||||
return {-1, Errno::BADF};
|
||||
}
|
||||
|
||||
FileDescriptor& descriptor = *file_descriptors[fd];
|
||||
|
||||
// For datagram sockets (UDP), a destination address is required
|
||||
if (!descriptor.is_connection_based && addr.empty()) {
|
||||
LOG_ERROR(Service, "SendTo called on datagram socket without destination address");
|
||||
return {-1, Errno::INVAL};
|
||||
}
|
||||
|
||||
Network::SockAddrIn addr_in;
|
||||
Network::SockAddrIn* p_addr_in = nullptr;
|
||||
if (!addr.empty()) {
|
||||
|
||||
@@ -205,6 +205,12 @@ std::pair<s32, Errno> ProxySocket::SendTo(u32 flags, std::span<const u8> message
|
||||
return {static_cast<s32>(message.size()), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
// For datagram sockets, a destination address is required
|
||||
if (!addr) {
|
||||
LOG_ERROR(Network, "SendTo called on ProxySocket without destination address");
|
||||
return {-1, Errno::INVAL};
|
||||
}
|
||||
|
||||
if (auto room_member = room_network.GetRoomMember().lock()) {
|
||||
if (!room_member->IsConnected()) {
|
||||
return {static_cast<s32>(message.size()), Errno::SUCCESS};
|
||||
|
||||
Reference in New Issue
Block a user