mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +00:00
Prefer using snprintf instead of insecure sprintf
This commit is contained in:
parent
b037da7264
commit
7bbdd6d18a
@ -129,7 +129,7 @@ void scope_repeat(scope_t *scope)
|
|||||||
gen->value.val_dec = (float)((int)gen->value.val_dec << gen->shift);
|
gen->value.val_dec = (float)((int)gen->value.val_dec << gen->shift);
|
||||||
else if (gen->shift < 0)
|
else if (gen->shift < 0)
|
||||||
gen->value.val_dec = (float)((int)gen->value.val_dec >> -gen->shift);
|
gen->value.val_dec = (float)((int)gen->value.val_dec >> -gen->shift);
|
||||||
sprintf(tmp, "%f", gen->value.val_dec);
|
snprintf(tmp, sizeof(tmp), "%f", gen->value.val_dec);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -138,7 +138,7 @@ void scope_repeat(scope_t *scope)
|
|||||||
gen->value.val_int <<= gen->shift;
|
gen->value.val_int <<= gen->shift;
|
||||||
else if (gen->shift < 0)
|
else if (gen->shift < 0)
|
||||||
gen->value.val_int >>= -gen->shift;
|
gen->value.val_int >>= -gen->shift;
|
||||||
sprintf(tmp, "%d", gen->value.val_int);
|
snprintf(tmp, sizeof(tmp), "%d", gen->value.val_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_set(¶m->value, tmp);
|
string_set(¶m->value, tmp);
|
||||||
|
@ -1235,7 +1235,13 @@ chd_error chd_get_metadata(chd_file *chd, UINT32 searchtag, UINT32 searchindex,
|
|||||||
UINT32 faux_length;
|
UINT32 faux_length;
|
||||||
|
|
||||||
/* fill in the faux metadata */
|
/* fill in the faux metadata */
|
||||||
sprintf(faux_metadata, HARD_DISK_METADATA_FORMAT, chd->header.obsolete_cylinders, chd->header.obsolete_heads, chd->header.obsolete_sectors, chd->header.hunkbytes / chd->header.obsolete_hunksize);
|
snprintf(faux_metadata,
|
||||||
|
sizeof(faux_metadata),
|
||||||
|
HARD_DISK_METADATA_FORMAT,
|
||||||
|
chd->header.obsolete_cylinders,
|
||||||
|
chd->header.obsolete_heads,
|
||||||
|
chd->header.obsolete_sectors,
|
||||||
|
chd->header.hunkbytes / chd->header.obsolete_hunksize);
|
||||||
faux_length = (UINT32)strlen(faux_metadata) + 1;
|
faux_length = (UINT32)strlen(faux_metadata) + 1;
|
||||||
|
|
||||||
/* copy the metadata itself */
|
/* copy the metadata itself */
|
||||||
|
@ -1025,7 +1025,7 @@ static int action_bind_sublabel_cpu_policy_entry_list(
|
|||||||
int idx = atoi(path);
|
int idx = atoi(path);
|
||||||
if (drivers)
|
if (drivers)
|
||||||
{
|
{
|
||||||
sprintf(s, "%s | Freq: %u MHz\n", drivers[idx]->scaling_governor,
|
snprintf(s, len, "%s | Freq: %u MHz\n", drivers[idx]->scaling_governor,
|
||||||
drivers[idx]->current_frequency / 1000);
|
drivers[idx]->current_frequency / 1000);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -10047,7 +10047,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
|||||||
while (*drivers)
|
while (*drivers)
|
||||||
{
|
{
|
||||||
char policyid[16];
|
char policyid[16];
|
||||||
sprintf(policyid, "%u", count++);
|
snprintf(policyid, sizeof(policyid), "%u", count++);
|
||||||
menu_entries_append_enum(info->list,
|
menu_entries_append_enum(info->list,
|
||||||
policyid,
|
policyid,
|
||||||
policyid,
|
policyid,
|
||||||
|
@ -197,9 +197,9 @@ bool set_cpu_scaling_min_frequency(
|
|||||||
{
|
{
|
||||||
char fpath[PATH_MAX_LENGTH];
|
char fpath[PATH_MAX_LENGTH];
|
||||||
char value[16];
|
char value[16];
|
||||||
sprintf(fpath, CPU_POLICIES_DIR "policy%u/scaling_min_freq",
|
snprintf(fpath, sizeof(fpath), CPU_POLICIES_DIR "policy%u/scaling_min_freq",
|
||||||
driver->policy_id);
|
driver->policy_id);
|
||||||
sprintf(value, "%" PRIu32 "\n", min_freq);
|
snprintf(value, sizeof(value), "%" PRIu32 "\n", min_freq);
|
||||||
if (filestream_write_file(fpath, value, strlen(value)))
|
if (filestream_write_file(fpath, value, strlen(value)))
|
||||||
{
|
{
|
||||||
driver->min_policy_freq = min_freq;
|
driver->min_policy_freq = min_freq;
|
||||||
@ -215,9 +215,9 @@ bool set_cpu_scaling_max_frequency(
|
|||||||
{
|
{
|
||||||
char fpath[PATH_MAX_LENGTH];
|
char fpath[PATH_MAX_LENGTH];
|
||||||
char value[16];
|
char value[16];
|
||||||
sprintf(fpath, CPU_POLICIES_DIR "policy%u/scaling_max_freq",
|
snprintf(fpath, sizeof(fpath), CPU_POLICIES_DIR "policy%u/scaling_max_freq",
|
||||||
driver->policy_id);
|
driver->policy_id);
|
||||||
sprintf(value, "%" PRIu32 "\n", max_freq);
|
snprintf(value, sizeof(value), "%" PRIu32 "\n", max_freq);
|
||||||
if (filestream_write_file(fpath, value, strlen(value)))
|
if (filestream_write_file(fpath, value, strlen(value)))
|
||||||
{
|
{
|
||||||
driver->max_policy_freq = max_freq;
|
driver->max_policy_freq = max_freq;
|
||||||
@ -294,7 +294,7 @@ uint32_t get_cpu_scaling_next_frequency_limit(uint32_t freq, int step)
|
|||||||
bool set_cpu_scaling_governor(cpu_scaling_driver_t *driver, const char* governor)
|
bool set_cpu_scaling_governor(cpu_scaling_driver_t *driver, const char* governor)
|
||||||
{
|
{
|
||||||
char fpath[PATH_MAX_LENGTH];
|
char fpath[PATH_MAX_LENGTH];
|
||||||
sprintf(fpath, CPU_POLICIES_DIR "policy%u/scaling_governor",
|
snprintf(fpath, sizeof(fpath), CPU_POLICIES_DIR "policy%u/scaling_governor",
|
||||||
driver->policy_id);
|
driver->policy_id);
|
||||||
if (filestream_write_file(fpath, governor, strlen(governor)))
|
if (filestream_write_file(fpath, governor, strlen(governor)))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user