From 73e5d955c320f557f70e25aac21fb0142360f989 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 9 Sep 2024 16:01:29 +0200 Subject: [PATCH] Downgrade some more variables to NAME_MAX_LENGTH --- frontend/drivers/platform_gx.c | 4 ++-- frontend/frontend_salamander.c | 4 ++-- manual_content_scan.c | 8 ++++---- manual_content_scan.h | 8 ++++---- menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_label.c | 2 +- menu/cbs/menu_cbs_ok.c | 22 ++++++++++------------ menu/cbs/menu_cbs_title.c | 2 +- menu/drivers/materialui.c | 5 +++-- menu/drivers/ozone.c | 13 ++++++------- menu/menu_displaylist.c | 18 +++++++++--------- menu/menu_driver.h | 8 ++++---- playlist.c | 14 +++++++------- runloop.c | 2 +- runtime_file.c | 4 ++-- tasks/task_database.c | 2 +- tasks/task_playlist_manager.c | 4 ++-- 17 files changed, 60 insertions(+), 62 deletions(-) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 16fe75d3f3..1136991c93 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -412,7 +412,7 @@ static void frontend_gx_exitspawn(char *s, size_t len, char *args) if (!string_is_empty(gx_rom_path)) should_load_game = true; #elif defined(HW_RVL) - char salamander_basename[PATH_MAX_LENGTH]; + char salamander_basename[NAME_MAX_LENGTH]; if (gx_fork_mode == FRONTEND_FORK_NONE) return; @@ -426,8 +426,8 @@ static void frontend_gx_exitspawn(char *s, size_t len, char *args) /* fall-through */ case FRONTEND_FORK_RESTART: { + char salamander_name[NAME_MAX_LENGTH]; char new_path[PATH_MAX_LENGTH]; - char salamander_name[PATH_MAX_LENGTH]; if (frontend_driver_get_salamander_basename(salamander_name, sizeof(salamander_name))) diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index b018ee9387..023c2998e2 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -60,8 +60,8 @@ static void find_first_libretro_core(char *first_file, for (i = 0; i < list->size && !ret; i++) { - char fname[PATH_MAX_LENGTH] = {0}; - char salamander_name[PATH_MAX_LENGTH] = {0}; + char salamander_name[NAME_MAX_LENGTH] = {0}; + char fname[NAME_MAX_LENGTH] = {0}; const char *libretro_elem = (const char*)list->elems[i].data; RARCH_LOG("Checking library: \"%s\".\n", libretro_elem); diff --git a/manual_content_scan.c b/manual_content_scan.c index fcb7a5d741..df9270bf41 100644 --- a/manual_content_scan.c +++ b/manual_content_scan.c @@ -42,11 +42,11 @@ typedef struct enum manual_content_scan_system_name_type system_name_type; enum manual_content_scan_core_type core_type; + char core_name[NAME_MAX_LENGTH]; + char system_name_database[NAME_MAX_LENGTH]; + char system_name_custom[NAME_MAX_LENGTH]; char content_dir[DIR_MAX_LENGTH]; char system_name_content_dir[DIR_MAX_LENGTH]; - char system_name_database[PATH_MAX_LENGTH]; - char system_name_custom[PATH_MAX_LENGTH]; - char core_name[NAME_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH]; char file_exts_core[PATH_MAX_LENGTH]; char file_exts_custom[PATH_MAX_LENGTH]; @@ -1356,7 +1356,7 @@ void manual_content_scan_add_content_to_playlist( if (!playlist_entry_exists(playlist, playlist_content_path)) { struct playlist_entry entry = {0}; - char label[PATH_MAX_LENGTH]; + char label[NAME_MAX_LENGTH]; label[0] = '\0'; diff --git a/manual_content_scan.h b/manual_content_scan.h index 66637a1dd2..a4a76db933 100644 --- a/manual_content_scan.h +++ b/manual_content_scan.h @@ -82,11 +82,11 @@ enum manual_content_scan_playlist_refresh_status * for a manual content scan task */ typedef struct { - char playlist_file[PATH_MAX_LENGTH]; + char core_name[NAME_MAX_LENGTH]; + char system_name[NAME_MAX_LENGTH]; + char database_name[NAME_MAX_LENGTH]; char content_dir[DIR_MAX_LENGTH]; - char system_name[PATH_MAX_LENGTH]; - char database_name[PATH_MAX_LENGTH]; - char core_name[PATH_MAX_LENGTH]; + char playlist_file[PATH_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH]; char file_exts[PATH_MAX_LENGTH]; char dat_file_path[PATH_MAX_LENGTH]; diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 66f3e1501b..f6e59eac52 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -1257,7 +1257,7 @@ static void menu_action_setting_disp_set_label_menu_file_directory( char *s2, size_t len2) { #if IOS - char tmp[PATH_MAX_LENGTH] = {0}; + char tmp[PATH_MAX_LENGTH]; fill_pathname_abbreviate_special(tmp, path, sizeof(tmp)); MENU_ACTION_SETTING_GENERIC_DISP_SET_LABEL_2(w, s, len, tmp, "(DIR)", STRLEN_CONST("(DIR)"), s2, len2); diff --git a/menu/cbs/menu_cbs_label.c b/menu/cbs/menu_cbs_label.c index 19798f0c0d..3ee9cdce71 100644 --- a/menu/cbs/menu_cbs_label.c +++ b/menu/cbs/menu_cbs_label.c @@ -78,7 +78,7 @@ static int action_bind_label_playlist_collection_entry( /* Handle collection playlists */ else { - char playlist_name[PATH_MAX_LENGTH]; + char playlist_name[NAME_MAX_LENGTH]; strlcpy(playlist_name, playlist_file, sizeof(playlist_name)); path_remove_extension(playlist_name); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 3df30213ff..428ecce897 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1512,7 +1512,7 @@ int generic_action_ok_displaylist_push( break; case ACTION_OK_DL_DATABASE_MANAGER_LIST: { - char lpl_basename[PATH_MAX_LENGTH]; + char lpl_basename[NAME_MAX_LENGTH]; struct menu_state *menu_st = menu_state_get_ptr(); filebrowser_clear_type(); fill_pathname_join_special(tmp, @@ -2633,7 +2633,7 @@ static int action_ok_playlist_entry_collection(const char *path, { playlist_config_t playlist_config; char content_path[PATH_MAX_LENGTH]; - char content_label[PATH_MAX_LENGTH]; + char content_label[NAME_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH]; size_t selection_ptr = entry_idx; bool playlist_initialized = false; @@ -5693,9 +5693,9 @@ static int action_ok_add_to_favorites(const char *path, if (!string_is_empty(content_path)) { union string_list_elem_attr attr; + char core_name[NAME_MAX_LENGTH]; + char content_label[NAME_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH]; - char core_name[PATH_MAX_LENGTH]; - char content_label[PATH_MAX_LENGTH]; runloop_state_t *runloop_st = runloop_state_get_ptr(); struct retro_system_info *sysinfo = &runloop_st->system.info; struct string_list *str_list = NULL; @@ -5832,11 +5832,10 @@ static int action_ok_add_entry_to_playlist(const char *path, if (!string_is_empty(entry->path)) { union string_list_elem_attr attr; - char core_display_name[PATH_MAX_LENGTH]; + char core_display_name[NAME_MAX_LENGTH]; + char core_name[NAME_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH]; - char core_name[PATH_MAX_LENGTH]; - struct string_list - *str_list = NULL; + struct string_list *str_list = NULL; core_display_name[0] = '\0'; core_path[0] = '\0'; @@ -5999,11 +5998,10 @@ static int action_ok_add_to_favorites_playlist(const char *path, if (!string_is_empty(entry->path)) { union string_list_elem_attr attr; - char core_display_name[PATH_MAX_LENGTH]; + char core_display_name[NAME_MAX_LENGTH]; + char core_name[NAME_MAX_LENGTH]; char core_path[PATH_MAX_LENGTH]; - char core_name[PATH_MAX_LENGTH]; - struct string_list - *str_list = NULL; + struct string_list *str_list = NULL; core_display_name[0] = '\0'; core_path[0] = '\0'; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 9cd5d40168..0e108f7c4a 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -413,7 +413,7 @@ static int action_get_title_deferred_playlist_list(const char *path, const char /* Handle collection playlists */ else { - char playlist_name[PATH_MAX_LENGTH]; + char playlist_name[NAME_MAX_LENGTH]; strlcpy(playlist_name, playlist_file, sizeof(playlist_name)); path_remove_extension(playlist_name); diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 0743016f3b..21e0c8e2d1 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -680,11 +680,12 @@ typedef struct materialui_handle enum materialui_landscape_layout_optimization_type last_landscape_layout_optimization; enum materialui_list_view_type list_view_type; - char sysicons_path[PATH_MAX_LENGTH]; - char icons_path[PATH_MAX_LENGTH]; + char msgbox[1024]; char menu_title[NAME_MAX_LENGTH]; char fullscreen_thumbnail_label[NAME_MAX_LENGTH]; + char sysicons_path[PATH_MAX_LENGTH]; + char icons_path[PATH_MAX_LENGTH]; } materialui_handle_t; static void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha) diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 29f861ee69..87cd9db5a8 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -617,14 +617,18 @@ struct ozone_handle uint8_t sidebar_index_list[SCROLL_INDEX_SIZE]; uint8_t sidebar_index_size; - char title[PATH_MAX_LENGTH]; + char title[NAME_MAX_LENGTH]; + char selection_core_name[NAME_MAX_LENGTH]; + char selection_playtime[NAME_MAX_LENGTH]; + char selection_lastplayed[NAME_MAX_LENGTH]; + char selection_entry_enumeration[NAME_MAX_LENGTH]; + char fullscreen_thumbnail_label[NAME_MAX_LENGTH]; char assets_path[PATH_MAX_LENGTH]; char png_path[PATH_MAX_LENGTH]; char icons_path[PATH_MAX_LENGTH]; char icons_path_default[PATH_MAX_LENGTH]; char tab_path[PATH_MAX_LENGTH]; - char fullscreen_thumbnail_label[NAME_MAX_LENGTH]; /* These have to be huge, because runloop_st->name.savestate * has a hard-coded size of 8192... @@ -633,11 +637,6 @@ struct ozone_handle char savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */ char prev_savestate_thumbnail_file_path[8204]; /* TODO/FIXME - check size */ - char selection_core_name[NAME_MAX_LENGTH]; - char selection_playtime[NAME_MAX_LENGTH]; - char selection_lastplayed[NAME_MAX_LENGTH]; - char selection_entry_enumeration[NAME_MAX_LENGTH]; - char thumbnails_left_status_prev; char thumbnails_right_status_prev; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 96ed055c42..6fe762c902 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2552,7 +2552,7 @@ static int create_string_list_rdb_entry_int( size_t _len; char str[16]; char tmp[128]; - char out_lbl[PATH_MAX_LENGTH]; + char out_lbl[NAME_MAX_LENGTH]; str[0] = '\0'; out_lbl[0] = '\0'; @@ -4516,7 +4516,7 @@ static unsigned menu_displaylist_parse_cores( #ifndef HAVE_DYNAMIC if (frontend_driver_has_fork()) { - char salamander_name[PATH_MAX_LENGTH]; + char salamander_name[NAME_MAX_LENGTH]; salamander_name[0] = '\0'; @@ -4587,10 +4587,10 @@ static unsigned menu_displaylist_parse_cores( static unsigned menu_displaylist_parse_add_to_playlist_list( file_list_t *list, settings_t *settings) { + char playlist_display_name[NAME_MAX_LENGTH]; unsigned count = 0; const char *dir_playlist = settings->paths.directory_playlist; bool show_hidden_files = settings->bools.show_hidden_files; - char playlist_display_name[PATH_MAX_LENGTH]; struct string_list *str_list = dir_list_new_special( dir_playlist, DIR_LIST_COLLECTIONS, NULL, show_hidden_files); @@ -5048,7 +5048,7 @@ static unsigned menu_displaylist_parse_content_information( if (!string_is_empty(db_name)) { char *db_name_no_ext = NULL; - char db_name_no_ext_buff[PATH_MAX_LENGTH]; + char db_name_no_ext_buff[NAME_MAX_LENGTH]; /* Remove .lpl extension * > path_remove_extension() requires a char * (not const) * so have to use a temporary buffer... */ @@ -12312,7 +12312,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, if (!string_is_empty(cd_info.title)) { /* TODO/FIXME - localize */ - char title[sizeof("Title: ") + sizeof(cd_info.title)]; /* TODO/FIXME - C89 compliance */ + char title[NAME_MAX_LENGTH]; size_t _len = strlcpy(title, "Title: ", sizeof(title)); strlcpy(title + _len, cd_info.title, sizeof(title) - _len); @@ -12687,7 +12687,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, for (i = 0; i < profiles_count; i++) { - char title[PATH_MAX_LENGTH]; + char title[NAME_MAX_LENGTH]; char* profile = SWITCH_CPU_PROFILES[i]; char* speed = SWITCH_CPU_SPEEDS[i]; size_t _len = strlcpy(title, profile, sizeof(title)); @@ -13133,7 +13133,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_CORE_CONTENT_DIRS_SUBDIR: { #ifdef HAVE_NETWORKING - char new_label[PATH_MAX_LENGTH]; + char new_label[NAME_MAX_LENGTH]; char *save = NULL; char *info_path_cpy = strdup(info->path); const char *con = strtok_r(info_path_cpy, ";", &save); @@ -13169,7 +13169,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_entries_clear(info->list); { #ifdef HAVE_NETWORKING - char new_label[PATH_MAX_LENGTH]; + char new_label[NAME_MAX_LENGTH]; const char * network_buildbot_assets_url = settings->paths.network_buildbot_assets_url; @@ -14988,7 +14988,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, case DISPLAYLIST_USER_BINDS_LIST: menu_entries_clear(info->list); { - char lbl[PATH_MAX_LENGTH]; + char lbl[NAME_MAX_LENGTH]; unsigned val = atoi(info->path); const char *temp_val = msg_hash_to_str( (enum msg_hash_enums)(MENU_ENUM_LABEL_INPUT_USER_1_BINDS + (val-1))); diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 0cf189c815..8979006ef2 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -434,8 +434,8 @@ typedef struct char pass_dir[DIR_MAX_LENGTH]; char preset_dir[DIR_MAX_LENGTH]; - char preset_file_name[PATH_MAX_LENGTH]; - char pass_file_name[PATH_MAX_LENGTH]; + char preset_file_name[NAME_MAX_LENGTH]; + char pass_file_name[NAME_MAX_LENGTH]; } last_shader_selection; #endif @@ -444,7 +444,7 @@ typedef struct struct { char directory[DIR_MAX_LENGTH]; - char file_name[PATH_MAX_LENGTH]; + char file_name[NAME_MAX_LENGTH]; } last_start_content; char menu_state_msg[8192]; @@ -456,7 +456,7 @@ typedef struct char scratch_buf[PATH_MAX_LENGTH]; char scratch2_buf[PATH_MAX_LENGTH]; char db_playlist_file[PATH_MAX_LENGTH]; - char filebrowser_label[PATH_MAX_LENGTH]; + char filebrowser_label[NAME_MAX_LENGTH]; char detect_content_path[PATH_MAX_LENGTH]; } menu_handle_t; diff --git a/playlist.c b/playlist.c index b42e7a7412..592b065d13 100644 --- a/playlist.c +++ b/playlist.c @@ -2760,7 +2760,7 @@ static bool playlist_read_file(playlist_t *playlist) else { char default_core_path[PATH_MAX_LENGTH]; - char default_core_name[PATH_MAX_LENGTH]; + char default_core_name[NAME_MAX_LENGTH]; default_core_path[0] = '\0'; default_core_name[0] = '\0'; @@ -3089,19 +3089,19 @@ static int playlist_qsort_func(const struct playlist_entry *a, * have no other option...) */ if (string_is_empty(a_str)) { - if (!(a_fallback_label = (char*)calloc(PATH_MAX_LENGTH, sizeof(char)))) + if (!(a_fallback_label = (char*)calloc(NAME_MAX_LENGTH, sizeof(char)))) goto end; if (!string_is_empty(a->path)) fill_pathname(a_fallback_label, path_basename_nocompression(a->path), "", - PATH_MAX_LENGTH * sizeof(char)); + NAME_MAX_LENGTH * sizeof(char)); /* If filename is also empty, use core name * instead -> this matches the behaviour of * menu_displaylist_parse_playlist() */ else if (!string_is_empty(a->core_name)) - strlcpy(a_fallback_label, a->core_name, PATH_MAX_LENGTH * sizeof(char)); + strlcpy(a_fallback_label, a->core_name, NAME_MAX_LENGTH * sizeof(char)); /* If both filename and core name are empty, * then have to compare an empty string @@ -3113,16 +3113,16 @@ static int playlist_qsort_func(const struct playlist_entry *a, if (string_is_empty(b_str)) { - if (!(b_fallback_label = (char*)calloc(PATH_MAX_LENGTH, sizeof(char)))) + if (!(b_fallback_label = (char*)calloc(NAME_MAX_LENGTH, sizeof(char)))) goto end; if (!string_is_empty(b->path)) fill_pathname(b_fallback_label, path_basename_nocompression(b->path), "", - PATH_MAX_LENGTH * sizeof(char)); + NAME_MAX_LENGTH * sizeof(char)); else if (!string_is_empty(b->core_name)) - strlcpy(b_fallback_label, b->core_name, PATH_MAX_LENGTH * sizeof(char)); + strlcpy(b_fallback_label, b->core_name, NAME_MAX_LENGTH * sizeof(char)); b_str = b_fallback_label; } diff --git a/runloop.c b/runloop.c index 724ab29fd5..8b871446ca 100644 --- a/runloop.c +++ b/runloop.c @@ -4148,7 +4148,7 @@ static bool runloop_path_init_subsystem(runloop_state_t *runloop_st) { char ext[32]; union string_list_elem_attr attr; - char savename[PATH_MAX_LENGTH]; + char savename[NAME_MAX_LENGTH]; char path[PATH_MAX_LENGTH]; size_t _len = 0; const struct retro_subsystem_memory_info *mem = diff --git a/runtime_file.c b/runtime_file.c index 3ba8572ed0..574da3d203 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -230,8 +230,8 @@ runtime_log_t *runtime_log_init( bool log_per_core) { char log_file_dir[DIR_MAX_LENGTH]; - char content_name[PATH_MAX_LENGTH]; - char core_name[PATH_MAX_LENGTH]; + char content_name[NAME_MAX_LENGTH]; + char core_name[nAME_MAX_LENGTH]; char log_file_path[PATH_MAX_LENGTH]; char tmp_buf[PATH_MAX_LENGTH]; bool supports_no_game = false; diff --git a/tasks/task_database.c b/tasks/task_database.c index 8e37b47fb4..52cc1a6773 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -1040,7 +1040,7 @@ static int task_database_iterate_playlist_lutro( if (!playlist_entry_exists(playlist, path)) { struct playlist_entry entry; - char game_title[PATH_MAX_LENGTH]; + char game_title[NAME_MAX_LENGTH]; fill_pathname(game_title, path_basename(path), "", sizeof(game_title)); path_remove_extension(game_title); diff --git a/tasks/task_playlist_manager.c b/tasks/task_playlist_manager.c index 545d5145eb..e0a5987895 100644 --- a/tasks/task_playlist_manager.c +++ b/tasks/task_playlist_manager.c @@ -388,7 +388,7 @@ static void pl_manager_validate_core_association( goto reset_core; else { - char core_display_name[PATH_MAX_LENGTH]; + char core_display_name[NAME_MAX_LENGTH]; core_info_t *core_info = NULL; /* Search core info */ @@ -706,7 +706,7 @@ bool task_push_pl_manager_clean_playlist( size_t _len; task_finder_data_t find_data; char task_title[128]; - char playlist_name[PATH_MAX_LENGTH]; + char playlist_name[NAME_MAX_LENGTH]; retro_task_t *task = task_init(); pl_manager_handle_t *pl_manager = (pl_manager_handle_t*) calloc(1, sizeof(pl_manager_handle_t));