Use snprintf over sprintf for safety

This commit is contained in:
Nightkingale 2024-07-31 18:35:11 -06:00
parent 8137beb776
commit e30893b7d0
2 changed files with 2 additions and 2 deletions

View File

@ -52,7 +52,7 @@ get_user_information()
// Get the user's persistent ID.
PERSISTENT_ID = nn::act::GetPersistentId();
char persistent_id_hex[9];
sprintf(persistent_id_hex, "%08x", PERSISTENT_ID);
snprintf(persistent_id_hex, sizeof persistent_id_hex, "%08x", PERSISTENT_ID);
// Set the account file path.
ACCOUNT_FILE = "storage_mlc:/usr/save/system/act/" + std::string(persistent_id_hex) + "/account.dat";

View File

@ -58,7 +58,7 @@ user_check(FILE* backup, account account_type)
// Prepare the search string, including the user's persistent ID.
char persistent_id_hex[9];
sprintf(persistent_id_hex, "%08x", PERSISTENT_ID);
snprintf(persistent_id_hex, sizeof persistent_id_hex, "%08x", PERSISTENT_ID);
std::string search_string = "PersistentId=" + std::string(persistent_id_hex);
bool found = false;
rewind(backup);