Relax SceNpCommunicationId validation

This commit is contained in:
RipleyTom 2025-10-21 09:54:57 +02:00 committed by Elad
parent 64e5a8c099
commit 6a028b1883
2 changed files with 3 additions and 2 deletions

View file

@ -24,7 +24,8 @@ namespace np
std::string communication_id_to_string(const SceNpCommunicationId& communicationId)
{
return fmt::format("%s_%02d", communicationId.data, communicationId.num);
const std::string com_id_data(communicationId.data, communicationId.data + 9);
return fmt::format("%s_%02d", com_id_data, communicationId.num);
}
void strings_to_userinfo(std::string_view npid, std::string_view online_name, std::string_view avatar_url, SceNpUserInfo& user_info)

View file

@ -2752,7 +2752,7 @@ namespace rpcn
void rpcn_client::write_communication_id(const SceNpCommunicationId& com_id, std::vector<u8>& data)
{
ensure(com_id.data[9] == 0 && com_id.num <= 99, "rpcn_client::write_communication_id: Invalid SceNpCommunicationId");
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");
const std::string com_id_str = np::communication_id_to_string(com_id);
ensure(com_id_str.size() == 12, "rpcn_client::write_communication_id: Error formatting SceNpCommunicationId");
memcpy(data.data(), com_id_str.data(), COMMUNICATION_ID_SIZE);