Skip to content

Commit 6a028b1

Browse files
RipleyTomelad335
authored andcommitted
Relax SceNpCommunicationId validation
1 parent 64e5a8c commit 6a028b1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

rpcs3/Emu/NP/np_helpers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ namespace np
2424

2525
std::string communication_id_to_string(const SceNpCommunicationId& communicationId)
2626
{
27-
return fmt::format("%s_%02d", communicationId.data, communicationId.num);
27+
const std::string com_id_data(communicationId.data, communicationId.data + 9);
28+
return fmt::format("%s_%02d", com_id_data, communicationId.num);
2829
}
2930

3031
void strings_to_userinfo(std::string_view npid, std::string_view online_name, std::string_view avatar_url, SceNpUserInfo& user_info)

rpcs3/Emu/NP/rpcn_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2752,7 +2752,7 @@ namespace rpcn
27522752

27532753
void rpcn_client::write_communication_id(const SceNpCommunicationId& com_id, std::vector<u8>& data)
27542754
{
2755-
ensure(com_id.data[9] == 0 && com_id.num <= 99, "rpcn_client::write_communication_id: Invalid SceNpCommunicationId");
2755+
ensure(std::all_of(com_id.data, com_id.data + 9, [](char c) { return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z'); }) && com_id.num <= 99, "rpcn_client::write_communication_id: Invalid SceNpCommunicationId");
27562756
const std::string com_id_str = np::communication_id_to_string(com_id);
27572757
ensure(com_id_str.size() == 12, "rpcn_client::write_communication_id: Error formatting SceNpCommunicationId");
27582758
memcpy(data.data(), com_id_str.data(), COMMUNICATION_ID_SIZE);

0 commit comments

Comments
 (0)