44#include " Emu/Cell/PPUCallback.h"
55#include " Emu/IdManager.h"
66#include " Emu/Cell/Modules/cellSysutil.h"
7+ #include " np_helpers.h"
78
89LOG_CHANNEL (sceNp2);
910
@@ -53,7 +54,7 @@ void generic_async_transaction_context::set_result_and_wake(error_code err)
5354
5455tus_ctx::tus_ctx (vm::cptr<SceNpCommunicationId> communicationId, vm::cptr<SceNpCommunicationPassphrase> passphrase)
5556{
56- ensure (! communicationId-> data [ 9 ] && strlen ( communicationId-> data ) == 9 );
57+ ensure (communicationId && np::validate_communication_id (* communicationId), " tus_ctx::tus_ctx: Invalid SceNpCommunicationId " );
5758 memcpy (&this ->communicationId , communicationId.get_ptr (), sizeof (SceNpCommunicationId));
5859 memcpy (&this ->passphrase , passphrase.get_ptr (), sizeof (SceNpCommunicationPassphrase));
5960}
@@ -96,7 +97,7 @@ bool destroy_tus_transaction_context(s32 ctx_id)
9697
9798score_ctx::score_ctx (vm::cptr<SceNpCommunicationId> communicationId, vm::cptr<SceNpCommunicationPassphrase> passphrase)
9899{
99- ensure (! communicationId-> data [ 9 ] && strlen ( communicationId-> data ) == 9 );
100+ ensure (communicationId && np::validate_communication_id (* communicationId), " score_ctx::score_ctx: Invalid SceNpCommunicationId " );
100101 memcpy (&this ->communicationId , communicationId.get_ptr (), sizeof (SceNpCommunicationId));
101102 memcpy (&this ->passphrase , passphrase.get_ptr (), sizeof (SceNpCommunicationPassphrase));
102103}
@@ -140,7 +141,7 @@ bool destroy_score_transaction_context(s32 ctx_id)
140141
141142match2_ctx::match2_ctx (vm::cptr<SceNpCommunicationId> communicationId, vm::cptr<SceNpCommunicationPassphrase> passphrase, s32 option)
142143{
143- ensure (! communicationId-> data [ 9 ] && strlen ( communicationId-> data ) == 9 );
144+ ensure (communicationId && np::validate_communication_id (* communicationId), " match2_ctx::match2_ctx: Invalid SceNpCommunicationId " );
144145 memcpy (&this ->communicationId , communicationId.get_ptr (), sizeof (SceNpCommunicationId));
145146 memcpy (&this ->passphrase , passphrase.get_ptr (), sizeof (SceNpCommunicationPassphrase));
146147
@@ -149,7 +150,7 @@ match2_ctx::match2_ctx(vm::cptr<SceNpCommunicationId> communicationId, vm::cptr<
149150}
150151u16 create_match2_context (vm::cptr<SceNpCommunicationId> communicationId, vm::cptr<SceNpCommunicationPassphrase> passphrase, s32 option)
151152{
152- sceNp2.notice (" Creating match2 context with communicationId: <%s>" , static_cast < const char *> (communicationId->data ));
153+ sceNp2.notice (" Creating match2 context with communicationId: <%s>" , std::string_view (communicationId->data , 9 ));
153154 return static_cast <u16 >(idm::make<match2_ctx>(communicationId, passphrase, option));
154155}
155156bool destroy_match2_context (u16 ctx_id)
@@ -167,7 +168,7 @@ shared_ptr<match2_ctx> get_match2_context(u16 ctx_id)
167168
168169lookup_title_ctx::lookup_title_ctx (vm::cptr<SceNpCommunicationId> communicationId)
169170{
170- ensure (! communicationId-> data [ 9 ] && strlen ( communicationId-> data ) == 9 );
171+ ensure (communicationId && np::validate_communication_id (* communicationId), " lookup_title_ctx::lookup_title_ctx: Invalid SceNpCommunicationId " );
171172 memcpy (&this ->communicationId , communicationId.get_ptr (), sizeof (SceNpCommunicationId));
172173}
173174s32 create_lookup_title_context (vm::cptr<SceNpCommunicationId> communicationId)
0 commit comments