From e97200a8841c1dfb17bb0614be06d62e9d08b901 Mon Sep 17 00:00:00 2001 From: Acts1631 Date: Tue, 6 Oct 2026 21:18:48 -0400 Subject: [PATCH] Reject invalid RPCN message types RPCN forwards MessageDetails from other users. The protobuf uint16 wrappers can carry 32-bit values, and narrowing them on the recipient aborts RPCS3. Validate both values before casting so malformed messages are discarded. --- rpcs3/Emu/NP/rpcn_client.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index deb4c9a0b7..885b29f825 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -3249,10 +3249,19 @@ namespace rpcn return; } + const u32 main_type = pb_mdata->maintype().value(); + const u32 sub_type = pb_mdata->subtype().value(); + + if (main_type > std::numeric_limits::max() || sub_type > std::numeric_limits::max()) + { + rpcn_log.warning("Discarded message with invalid type! (main_type=%u, sub_type=%u)", main_type, sub_type); + return; + } + message_data mdata = { .msgId = message_counter, - .mainType = ::narrow(pb_mdata->maintype().value()), - .subType = ::narrow(pb_mdata->subtype().value()), + .mainType = static_cast(main_type), + .subType = static_cast(sub_type), .msgFeatures = pb_mdata->msgfeatures(), .subject = pb_mdata->subject(), .body = pb_mdata->body()};