Replace sprintf with snprintf to silence compiler warning

This fixes the following compiler deprecation warning

`warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.`
This commit is contained in:
shinra-electric 2022-10-08 13:48:59 +02:00 committed by kd-11
parent e0df2c584f
commit fa744e53d3

View File

@ -265,7 +265,7 @@ namespace pine
case MsgVersion:
{
char version[256] = {};
sprintf(version, "RPCS3 %s", Impl::get_version_and_branch().c_str());
snprintf(version, sizeof(version), "RPCS3 %s", Impl::get_version_and_branch().c_str());
const u32 size = strlen(version) + 1;
version[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
@ -291,7 +291,7 @@ namespace pine
const auto title_string = Impl::get_title();
const auto size = title_string.size() + 1;
char* title = new char[size];
sprintf(title, "%s", title_string.c_str());
snprintf(title, sizeof(title), "%s", title_string.c_str());
title[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error;
@ -307,7 +307,7 @@ namespace pine
const auto title_id_string = Impl::get_title_ID();
const auto size = title_id_string.size() + 1;
char* title_id = new char[size];
sprintf(title_id, "%s", title_id_string.c_str());
snprintf(title_id, sizeof(title_id), "%s", title_id_string.c_str());
title_id[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error;
@ -323,7 +323,7 @@ namespace pine
const auto hash_string = Impl::get_executable_hash();
const auto size = hash_string.size() + 1;
char* hash = new char[size];
sprintf(hash, "%s", hash_string.c_str());
snprintf(hash, sizeof(hash), "%s", hash_string.c_str());
hash[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size + 4, buf_size))
goto error;
@ -339,7 +339,7 @@ namespace pine
const auto game_version_string = Impl::get_app_version();
const auto size = game_version_string.size() + 1;
char* game_version = new char[size];
sprintf(game_version, "%s", game_version_string.c_str());
snprintf(game_version, sizeof(game_version), "%s", game_version_string.c_str());
game_version[size] = 0x00;
if (!SafetyChecks(buf_cnt, 0, ret_cnt, size, buf_size))
goto error;