From 966fa1cab3b2b39b5cd239ee07c7512dd04fa05c Mon Sep 17 00:00:00 2001 From: zeph Date: Mon, 8 Dec 2025 02:59:05 +0100 Subject: [PATCH] Clans: code styling & safety fix-ups --- rpcs3/Emu/Cell/Modules/sceNpClans.cpp | 3 --- rpcs3/Emu/Cell/Modules/sceNpClans.h | 2 +- rpcs3/Emu/NP/clans_client.cpp | 34 +++++++++++++-------------- rpcs3/Emu/NP/clans_client.h | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sceNpClans.cpp b/rpcs3/Emu/Cell/Modules/sceNpClans.cpp index 737e481745..45e499a6a9 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpClans.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpClans.cpp @@ -1063,9 +1063,6 @@ error_code sceNpClansPostChallenge(vm::ptr handle, SceN return SCE_NP_CLANS_ERROR_EXCEEDS_MAX; } - vm::var req; - vm::write32(handle.addr(), req.addr()); - return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/sceNpClans.h b/rpcs3/Emu/Cell/Modules/sceNpClans.h index d5b6df415a..6e4585ed43 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpClans.h +++ b/rpcs3/Emu/Cell/Modules/sceNpClans.h @@ -282,4 +282,4 @@ struct SceNpClansBlacklistEntry { SceNpId entry; SceNpId registeredBy; -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/NP/clans_client.cpp b/rpcs3/Emu/NP/clans_client.cpp index a557f0804c..50e57daddc 100644 --- a/rpcs3/Emu/NP/clans_client.cpp +++ b/rpcs3/Emu/NP/clans_client.cpp @@ -1,3 +1,4 @@ +#include "Utilities/StrUtil.h" #include "stdafx.h" #include "util/types.hpp" @@ -348,8 +349,8 @@ namespace clan .role = static_cast(role_int), .status = static_cast(status_int)}; - snprintf(entry.info.name, sizeof(entry.info.name), "%s", name_str.c_str()); - snprintf(entry.info.tag, sizeof(entry.info.tag), "%s", tag_str.c_str()); + strcpy_trunc(entry.info.name, name_str.c_str()); + strcpy_trunc(entry.info.tag, tag_str.c_str()); clanList[i] = entry; i++; @@ -394,9 +395,9 @@ namespace clan .description = "", }}; - snprintf(clanInfo->info.name, sizeof(clanInfo->info.name), "%s", name_str.c_str()); - snprintf(clanInfo->info.tag, sizeof(clanInfo->info.tag), "%s", tag_str.c_str()); - snprintf(clanInfo->updatable.description, sizeof(clanInfo->updatable.description), "%s", description_str.c_str()); + strcpy_trunc(clanInfo->info.name, name_str.c_str()); + strcpy_trunc(clanInfo->info.tag, tag_str.c_str()); + strcpy_trunc(clanInfo->updatable.description, description_str.c_str()); return SCE_NP_CLANS_SUCCESS; } @@ -451,7 +452,7 @@ namespace clan std::string description_str = description.text().as_string(); char description_char[256] = {0}; - snprintf(description_char, sizeof(description_char), "%s", description_str.c_str()); + strcpy_trunc(description_char, description_str.c_str()); *memInfo = SceNpClansMemberEntry { @@ -463,8 +464,8 @@ namespace clan } }; - snprintf(memInfo->npid.handle.data, sizeof(memInfo->npid.handle.data), "%s", username); - snprintf(memInfo->updatable.description, sizeof(memInfo->updatable.description), "%s", description_char); + strcpy_trunc(memInfo->npid.handle.data, username); + strcpy_trunc(memInfo->updatable.description, description_char); return SCE_NP_CLANS_SUCCESS; } @@ -521,7 +522,7 @@ namespace clan std::string description_str = info.child("description").text().as_string(); char description_char[256] = {0}; - snprintf(description_char, sizeof(description_char), "%s", description_str.c_str()); + strcpy_trunc(description_char, description_str.c_str()); SceNpClansMemberEntry entry = SceNpClansMemberEntry { @@ -530,7 +531,7 @@ namespace clan .status = static_cast(status_int), }; - snprintf(entry.updatable.description, sizeof(entry.updatable.description), "%s", description_char); + strcpy_trunc(entry.updatable.description, description_char); memList[i] = entry; i++; @@ -589,7 +590,7 @@ namespace clan } }; - snprintf(npid.handle.data, sizeof(npid.handle.data), "%s", username); + strcpy_trunc(npid.handle.data, username); SceNpClansBlacklistEntry entry = SceNpClansBlacklistEntry { @@ -687,8 +688,8 @@ namespace clan .reserved = {0, 0}, }; - snprintf(entry.name, sizeof(entry.name), "%s", name_str.c_str()); - snprintf(entry.tag, sizeof(entry.tag), "%s", tag_str.c_str()); + strcpy_trunc(entry.name, name_str.c_str()); + strcpy_trunc(entry.tag, tag_str.c_str()); clanList[i] = entry; i++; @@ -971,9 +972,8 @@ namespace clan .postedBy = clanId, }; - - snprintf(entry.message.subject, sizeof(entry.message.subject), "%s", subject_str.c_str()); - snprintf(entry.message.body, sizeof(entry.message.body), "%s", msg_str.c_str()); + strcpy_trunc(entry.message.subject, subject_str.c_str()); + strcpy_trunc(entry.message.body, msg_str.c_str()); announcements[i] = entry; i++; @@ -1033,4 +1033,4 @@ namespace clan return sendRequest(ClanRequestAction::DeleteAnnouncement, ClanManagerOperationType::UPDATE, &doc, &response); } } -#pragma endregion \ No newline at end of file +#pragma endregion diff --git a/rpcs3/Emu/NP/clans_client.h b/rpcs3/Emu/NP/clans_client.h index c488f6be8a..57aadad3b4 100644 --- a/rpcs3/Emu/NP/clans_client.h +++ b/rpcs3/Emu/NP/clans_client.h @@ -117,4 +117,4 @@ struct sce_np_clans_manager { atomic_t is_initialized = false; clan::clans_client* client; -}; \ No newline at end of file +};