service/nwm_uds: log instead of assert to prevent crashes during multiplayer in Monster Hunter games (#6161)

This commit is contained in:
tywald 2022-10-23 19:40:41 +02:00 committed by GitHub
parent 9626bdf385
commit a2daef2985
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -491,7 +491,10 @@ void NWM_UDS::HandleDeauthenticationFrame(const Network::WifiPacket& packet) {
auto node_it = std::find_if(node_info.begin(), node_info.end(), [&node](const NodeInfo& info) { auto node_it = std::find_if(node_info.begin(), node_info.end(), [&node](const NodeInfo& info) {
return info.network_node_id == node.node_id; return info.network_node_id == node.node_id;
}); });
ASSERT(node_it != node_info.end()); if (node_it == node_info.end()) {
LOG_ERROR(Service_NWM, "node_it is last node of node_info");
return;
}
connection_status.node_bitmask &= ~(1 << (node.node_id - 1)); connection_status.node_bitmask &= ~(1 << (node.node_id - 1));
connection_status.changed_nodes |= 1 << (node.node_id - 1); connection_status.changed_nodes |= 1 << (node.node_id - 1);
@ -1096,9 +1099,6 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) {
u32 data_size = rp.Pop<u32>(); u32 data_size = rp.Pop<u32>();
u8 flags = rp.Pop<u8>(); u8 flags = rp.Pop<u8>();
// There should never be a dest_node_id of 0
ASSERT(dest_node_id != 0);
std::vector<u8> input_buffer = rp.PopStaticBuffer(); std::vector<u8> input_buffer = rp.PopStaticBuffer();
ASSERT(input_buffer.size() >= data_size); ASSERT(input_buffer.size() >= data_size);
input_buffer.resize(data_size); input_buffer.resize(data_size);
@ -1113,6 +1113,14 @@ void NWM_UDS::SendTo(Kernel::HLERequestContext& ctx) {
return; return;
} }
// There should never be a dest_node_id of 0
if (dest_node_id == 0) {
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,
ErrorSummary::WrongArgument, ErrorLevel::Status));
LOG_ERROR(Service_NWM, "dest_node_id is 0");
return;
}
if (dest_node_id == connection_status.network_node_id) { if (dest_node_id == connection_status.network_node_id) {
LOG_ERROR(Service_NWM, "tried to send packet to itself"); LOG_ERROR(Service_NWM, "tried to send packet to itself");
rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS, rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::UDS,