1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Use single snprintf instead of multiple strlcpy/strlcat calls in

several places
This commit is contained in:
twinaphex 2021-05-18 23:18:09 +02:00
parent 0482892a9c
commit 925c459aed
2 changed files with 22 additions and 15 deletions

View File

@ -3656,20 +3656,23 @@ bool config_load_override(void *data)
{
char temp_path[PATH_MAX_LENGTH];
temp_path[0] = '\0';
RARCH_LOG("[Overrides]: Content dir-specific overrides found at \"%s\".\n",
content_path);
if (should_append)
{
RARCH_LOG("[Overrides]: Content dir-specific overrides stacking on top of previous overrides.\n");
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), sizeof(temp_path));
strlcat(temp_path, "|", sizeof(temp_path));
strlcat(temp_path, content_path, sizeof(temp_path));
snprintf(temp_path, sizeof(temp_path),
"%s|%s",
path_get(RARCH_PATH_CONFIG_APPEND),
content_path
);
}
else
{
temp_path[0] = '\0';
strlcpy(temp_path, content_path, sizeof(temp_path));
}
path_set(RARCH_PATH_CONFIG_APPEND, temp_path);
@ -3685,20 +3688,23 @@ bool config_load_override(void *data)
{
char temp_path[PATH_MAX_LENGTH];
temp_path[0] = '\0';
RARCH_LOG("[Overrides]: Game-specific overrides found at \"%s\".\n",
game_path);
if (should_append)
{
RARCH_LOG("[Overrides]: Game-specific overrides stacking on top of previous overrides.\n");
strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), sizeof(temp_path));
strlcat(temp_path, "|", sizeof(temp_path));
strlcat(temp_path, game_path, sizeof(temp_path));
snprintf(temp_path, sizeof(temp_path),
"%s|%s",
path_get(RARCH_PATH_CONFIG_APPEND),
game_path
);
}
else
{
temp_path[0] = '\0';
strlcpy(temp_path, game_path, sizeof(temp_path));
}
path_set(RARCH_PATH_CONFIG_APPEND, temp_path);

View File

@ -1490,15 +1490,16 @@ static config_file_t *core_info_get_config_file(
{
char info_path[PATH_MAX_LENGTH];
info_path[0] = '\0';
if (string_is_empty(info_dir))
strlcpy(info_path, core_file_id, sizeof(info_path));
snprintf(info_path, sizeof(info_path),
"%s" ".info", core_file_id);
else
{
info_path[0] = '\0';
fill_pathname_join(info_path, info_dir, core_file_id,
sizeof(info_path));
strlcat(info_path, ".info", sizeof(info_path));
strlcat(info_path, ".info", sizeof(info_path));
}
return config_file_new_from_path_to_string(info_path);
}