mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
String stack size cleanups
This commit is contained in:
parent
a85368f21f
commit
dc3dc574d8
@ -1847,13 +1847,20 @@ static int generic_action_ok(const char *path,
|
||||
case ACTION_OK_SET_DIRECTORY:
|
||||
flush_char = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DIRECTORY_SETTINGS_LIST);
|
||||
#ifdef HAVE_COCOATOUCH
|
||||
// For iOS, set the path using realpath because the path name
|
||||
// can start with /private and this ensures the path starts with it.
|
||||
// This will allow the path to be properly substituted when fill_pathname_expand_special
|
||||
// is called.
|
||||
char real_action_path[PATH_MAX_LENGTH] = {0};
|
||||
realpath(action_path, real_action_path);
|
||||
strlcpy(action_path, real_action_path, sizeof(action_path));
|
||||
/* For iOS, set the path using realpath because the
|
||||
* path name can start with /private and this ensures
|
||||
* the path starts with it.
|
||||
*
|
||||
* This will allow the path to be properly substituted
|
||||
* when fill_pathname_expand_special
|
||||
* is called.
|
||||
*/
|
||||
{
|
||||
char real_action_path[PATH_MAX_LENGTH];
|
||||
real_action_path[0] = '\0';
|
||||
realpath(action_path, real_action_path);
|
||||
strlcpy(action_path, real_action_path, sizeof(action_path));
|
||||
}
|
||||
#endif
|
||||
ret = set_path_generic(menu->filebrowser_label, action_path);
|
||||
break;
|
||||
@ -3228,7 +3235,8 @@ static int action_ok_path_manual_scan_directory(const char *path,
|
||||
* can start with /private and this ensures the path starts with it.
|
||||
* This will allow the path to be properly substituted when
|
||||
* fill_pathname_expand_special() is called. */
|
||||
char real_content_dir[PATH_MAX_LENGTH] = {0};
|
||||
char real_content_dir[PATH_MAX_LENGTH];
|
||||
real_content_dir[0] = '\0';
|
||||
realpath(content_dir, real_content_dir);
|
||||
strlcpy(content_dir, real_content_dir, sizeof(content_dir));
|
||||
}
|
||||
@ -3350,8 +3358,10 @@ static int action_ok_set_switch_cpu_profile(const char *path,
|
||||
static int action_ok_set_switch_gpu_profile(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
char *profile_name = SWITCH_GPU_PROFILES[entry_idx];
|
||||
char command[PATH_MAX_LENGTH] = {0};
|
||||
char command[PATH_MAX_LENGTH];
|
||||
char *profile_name = SWITCH_GPU_PROFILES[entry_idx];
|
||||
|
||||
command[0] = '\0';
|
||||
|
||||
snprintf(command, sizeof(command),
|
||||
"gpu-profile set '%s'",
|
||||
@ -4238,13 +4248,10 @@ void cb_generic_download(retro_task_t *task,
|
||||
dir_path = LAKKA_UPDATE_DIR;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CB_DISCORD_AVATAR:
|
||||
{
|
||||
fill_pathname_application_special(buf,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
||||
fill_pathname_application_special(buf, sizeof(buf),
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
||||
dir_path = buf;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
RARCH_WARN("Unknown transfer type '%s' bailing out.\n",
|
||||
msg_hash_to_str(transf->enum_idx));
|
||||
@ -4655,12 +4662,12 @@ static int action_ok_add_to_favorites(const char *path,
|
||||
char core_name[PATH_MAX_LENGTH];
|
||||
|
||||
content_label[0] = '\0';
|
||||
core_path[0] = '\0';
|
||||
core_name[0] = '\0';
|
||||
core_path[0] = '\0';
|
||||
core_name[0] = '\0';
|
||||
|
||||
/* Create string list container for playlist parameters */
|
||||
attr.i = 0;
|
||||
str_list = string_list_new();
|
||||
attr.i = 0;
|
||||
str_list = string_list_new();
|
||||
if (!str_list)
|
||||
return 0;
|
||||
|
||||
@ -6328,6 +6335,7 @@ static int action_ok_disk_cycle_tray_status(const char *path,
|
||||
static int action_ok_disk_image_append(const char *path,
|
||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||
{
|
||||
char image_path[PATH_MAX_LENGTH];
|
||||
rarch_system_info_t *sys_info = runloop_get_system_info();
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
const char *menu_path = NULL;
|
||||
@ -6337,9 +6345,8 @@ static int action_ok_disk_image_append(const char *path,
|
||||
bool audio_enable_menu_ok = settings->bools.audio_enable_menu_ok;
|
||||
#endif
|
||||
bool menu_insert_disk_resume = settings->bools.menu_insert_disk_resume;
|
||||
char image_path[PATH_MAX_LENGTH];
|
||||
|
||||
image_path[0] = '\0';
|
||||
image_path[0] = '\0';
|
||||
|
||||
if (!menu)
|
||||
return menu_cbs_exit();
|
||||
|
@ -892,7 +892,7 @@ static void stripes_update_thumbnail_path(void *data, unsigned i, char pos)
|
||||
{
|
||||
menu_entry_t entry;
|
||||
unsigned entry_type = 0;
|
||||
char new_path[PATH_MAX_LENGTH] = {0};
|
||||
char new_path[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
stripes_handle_t *stripes = (stripes_handle_t*)data;
|
||||
playlist_t *playlist = NULL;
|
||||
@ -901,6 +901,8 @@ static void stripes_update_thumbnail_path(void *data, unsigned i, char pos)
|
||||
if (!stripes || string_is_empty(dir_thumbnails))
|
||||
goto end;
|
||||
|
||||
new_path[0] = '\0';
|
||||
|
||||
menu_entry_init(&entry);
|
||||
menu_entry_get(&entry, 0, i, NULL, true);
|
||||
|
||||
@ -2387,7 +2389,9 @@ static int stripes_draw_item(
|
||||
|
||||
if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY)
|
||||
{
|
||||
char entry_path[PATH_MAX_LENGTH] = {0};
|
||||
char entry_path[PATH_MAX_LENGTH];
|
||||
|
||||
entry_path[0] = '\0';
|
||||
strlcpy(entry_path, entry->path, sizeof(entry_path));
|
||||
|
||||
fill_short_pathname_representation(entry_path, entry_path,
|
||||
@ -3727,28 +3731,21 @@ static void stripes_context_reset_textures(
|
||||
|
||||
static void stripes_context_reset_background(const char *iconpath)
|
||||
{
|
||||
char *path = NULL;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *path_menu_wp = settings->paths.path_menu_wallpaper;
|
||||
|
||||
if (!string_is_empty(path_menu_wp))
|
||||
path = strdup(path_menu_wp);
|
||||
else if (!string_is_empty(iconpath))
|
||||
{
|
||||
path = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
path[0] = '\0';
|
||||
path[0] = '\0';
|
||||
|
||||
fill_pathname_join(path, iconpath, "bg.png",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
}
|
||||
if (!string_is_empty(path_menu_wp))
|
||||
strlcpy(path, path_menu_wp, sizeof(path));
|
||||
else if (!string_is_empty(iconpath))
|
||||
fill_pathname_join(path, iconpath, "bg.png", sizeof(path));
|
||||
|
||||
if (path_is_valid(path))
|
||||
task_push_image_load(path,
|
||||
video_driver_supports_rgba(), 0,
|
||||
menu_display_handle_wallpaper_upload, NULL);
|
||||
|
||||
if (path)
|
||||
free(path);
|
||||
}
|
||||
|
||||
static void stripes_context_reset(void *data, bool is_threaded)
|
||||
@ -3757,9 +3754,9 @@ static void stripes_context_reset(void *data, bool is_threaded)
|
||||
|
||||
if (stripes)
|
||||
{
|
||||
char bg_file_path[PATH_MAX_LENGTH] = {0};
|
||||
char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
iconpath[0] = '\0';
|
||||
char iconpath [PATH_MAX_LENGTH];
|
||||
char bg_file_path[PATH_MAX_LENGTH];
|
||||
iconpath[0] = bg_file_path[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(bg_file_path,
|
||||
sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG);
|
||||
@ -3771,8 +3768,7 @@ static void stripes_context_reset(void *data, bool is_threaded)
|
||||
stripes->bg_file_path = strdup(bg_file_path);
|
||||
}
|
||||
|
||||
fill_pathname_application_special(iconpath,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
fill_pathname_application_special(iconpath, sizeof(iconpath),
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_ICONS);
|
||||
|
||||
stripes_layout(stripes);
|
||||
@ -3793,8 +3789,6 @@ static void stripes_context_reset(void *data, bool is_threaded)
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)))
|
||||
stripes_update_thumbnail_image(stripes);
|
||||
stripes_update_savestate_thumbnail_image(stripes);
|
||||
|
||||
free(iconpath);
|
||||
}
|
||||
video_driver_monitor_reset();
|
||||
}
|
||||
|
@ -2211,10 +2211,9 @@ static void xmb_context_reset_horizontal_list(
|
||||
|
||||
if (!path_is_valid(content_texturepath))
|
||||
{
|
||||
strlcat(iconpath, "default", PATH_MAX_LENGTH * sizeof(char));
|
||||
strlcat(iconpath, "default", sizeof(iconpath));
|
||||
fill_pathname_join_delim(content_texturepath, iconpath,
|
||||
"content.png", '-',
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
"content.png", '-', sizeof(content_texturepath));
|
||||
}
|
||||
|
||||
if (image_texture_load(&ti, content_texturepath))
|
||||
@ -3098,7 +3097,8 @@ static int xmb_draw_item(
|
||||
|
||||
if (entry_type == FILE_TYPE_CONTENTLIST_ENTRY)
|
||||
{
|
||||
char entry_path[PATH_MAX_LENGTH] = {0};
|
||||
char entry_path[PATH_MAX_LENGTH];
|
||||
entry_path[0] = '\0';
|
||||
strlcpy(entry_path, entry.path, sizeof(entry_path));
|
||||
|
||||
fill_short_pathname_representation(entry_path, entry_path,
|
||||
@ -6030,8 +6030,7 @@ static void xmb_context_reset_background(const char *iconpath)
|
||||
char path[PATH_MAX_LENGTH];
|
||||
path[0] = '\0';
|
||||
|
||||
fill_pathname_join(path, iconpath, "bg.png",
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
fill_pathname_join(path, iconpath, "bg.png", sizeof(path));
|
||||
if (path_is_valid(path))
|
||||
task_push_image_load(path,
|
||||
video_driver_supports_rgba(), 0,
|
||||
@ -6049,8 +6048,8 @@ static void xmb_context_reset_internal(xmb_handle_t *xmb,
|
||||
bool is_threaded, bool reinit_textures)
|
||||
{
|
||||
char iconpath[PATH_MAX_LENGTH];
|
||||
char bg_file_path[PATH_MAX_LENGTH] = {0};
|
||||
iconpath[0] = '\0';
|
||||
char bg_file_path[PATH_MAX_LENGTH];
|
||||
iconpath[0] = bg_file_path[0] = '\0';
|
||||
|
||||
fill_pathname_application_special(bg_file_path,
|
||||
sizeof(bg_file_path), APPLICATION_SPECIAL_DIRECTORY_ASSETS_XMB_BG);
|
||||
|
@ -1582,17 +1582,15 @@ static int create_string_list_rdb_entry_string(
|
||||
file_list_t *list)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
char *tmp = NULL;
|
||||
char tmp[PATH_MAX_LENGTH];
|
||||
char *output_label = NULL;
|
||||
int str_len = 0;
|
||||
struct string_list *str_list = string_list_new();
|
||||
size_t path_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
|
||||
if (!str_list)
|
||||
return -1;
|
||||
|
||||
attr.i = 0;
|
||||
tmp = (char*)malloc(path_size);
|
||||
tmp[0] = '\0';
|
||||
|
||||
str_len += strlen(label) + 1;
|
||||
@ -1609,7 +1607,6 @@ static int create_string_list_rdb_entry_string(
|
||||
if (!output_label)
|
||||
{
|
||||
string_list_free(str_list);
|
||||
free(tmp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1617,13 +1614,12 @@ static int create_string_list_rdb_entry_string(
|
||||
string_list_free(str_list);
|
||||
|
||||
fill_pathname_join_concat_noext(tmp, desc, ": ",
|
||||
actual_string, path_size);
|
||||
actual_string, sizeof(tmp));
|
||||
menu_entries_append_enum(list, tmp, output_label,
|
||||
enum_idx,
|
||||
0, 0, 0);
|
||||
|
||||
free(output_label);
|
||||
free(tmp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
23
retroarch.c
23
retroarch.c
@ -14651,9 +14651,8 @@ static void command_event_load_auto_state(
|
||||
global_t *global,
|
||||
struct rarch_state *p_rarch)
|
||||
{
|
||||
char savestate_name_auto[PATH_MAX_LENGTH];
|
||||
bool ret = false;
|
||||
char *savestate_name_auto = NULL;
|
||||
size_t savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
bool savestate_auto_load = settings->bools.savestate_auto_load;
|
||||
|
||||
if (!global || !savestate_auto_load)
|
||||
@ -14667,17 +14666,13 @@ static void command_event_load_auto_state(
|
||||
return;
|
||||
#endif
|
||||
|
||||
savestate_name_auto = (char*)calloc(PATH_MAX_LENGTH,
|
||||
sizeof(*savestate_name_auto));
|
||||
savestate_name_auto[0] = '\0';
|
||||
|
||||
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
||||
".auto", savestate_name_auto_size);
|
||||
".auto", sizeof(savestate_name_auto));
|
||||
|
||||
if (!path_is_valid(savestate_name_auto))
|
||||
{
|
||||
free(savestate_name_auto);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = content_load_state(savestate_name_auto, false, true);
|
||||
|
||||
@ -14687,8 +14682,6 @@ static void command_event_load_auto_state(
|
||||
msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FROM),
|
||||
savestate_name_auto, ret ? "succeeded" : "failed"
|
||||
);
|
||||
|
||||
free(savestate_name_auto);
|
||||
}
|
||||
|
||||
static void command_event_set_savestate_auto_index(
|
||||
@ -15054,9 +15047,7 @@ static bool command_event_save_auto_state(
|
||||
struct rarch_state *p_rarch)
|
||||
{
|
||||
bool ret = false;
|
||||
char *savestate_name_auto = NULL;
|
||||
size_t
|
||||
savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char);
|
||||
char savestate_name_auto[PATH_MAX_LENGTH];
|
||||
bool savestate_auto_save = settings->bools.savestate_auto_save;
|
||||
const enum rarch_core_type
|
||||
current_core_type = p_rarch->current_core_type;
|
||||
@ -15074,11 +15065,10 @@ static bool command_event_save_auto_state(
|
||||
return false;
|
||||
#endif
|
||||
|
||||
savestate_name_auto = (char*)
|
||||
calloc(PATH_MAX_LENGTH, sizeof(*savestate_name_auto));
|
||||
savestate_name_auto[0] = '\0';
|
||||
|
||||
fill_pathname_noext(savestate_name_auto, global->name.savestate,
|
||||
".auto", savestate_name_auto_size);
|
||||
".auto", sizeof(savestate_name_auto));
|
||||
|
||||
ret = content_save_state((const char*)savestate_name_auto, true, true);
|
||||
RARCH_LOG("%s \"%s\" %s.\n",
|
||||
@ -15086,7 +15076,6 @@ static bool command_event_save_auto_state(
|
||||
savestate_name_auto, ret ?
|
||||
"succeeded" : "failed");
|
||||
|
||||
free(savestate_name_auto);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user