From 3a67e072bb5f7aaeddeae42ab18ecf6aaacbc869 Mon Sep 17 00:00:00 2001 From: Barry Rowe Date: Wed, 4 Dec 2019 10:51:50 -0800 Subject: [PATCH] Added in fixes for accessibility feature. --- menu/drivers/menu_generic.c | 24 ++++++++++++------------ menu/menu_driver.c | 12 ++++++------ menu/menu_entries.h | 6 +++--- retroarch.c | 13 +++++++++---- retroarch.h | 14 +++++++------- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 7cbcdb4835..8c6518361a 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -154,7 +154,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) if (strcmp(menu->menu_state_msg, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_INFORMATION_AVAILABLE))==0) { char current_sublabel[255]; - get_current_menu_sublabel(current_sublabel); + get_current_menu_sublabel(current_sublabel, 255); if (strcmp(current_sublabel, "")==0) accessibility_speak(menu->menu_state_msg); else @@ -420,9 +420,9 @@ int generic_menu_entry_action( char title_name[255]; char speak_string[512]; - strcpy(title_name, ""); - strcpy(current_label, ""); - get_current_menu_value(current_value); + strlcpy(title_name, "",1); + strlcpy(current_label, "",1); + get_current_menu_value(current_value, 255); switch (action) { case MENU_ACTION_INFO: @@ -436,29 +436,29 @@ int generic_menu_entry_action( case MENU_ACTION_DOWN: case MENU_ACTION_SCROLL_UP: case MENU_ACTION_SCROLL_DOWN: - get_current_menu_label(current_label); + get_current_menu_label(current_label, 255); break; case MENU_ACTION_START: case MENU_ACTION_SELECT: case MENU_ACTION_SEARCH: - get_current_menu_label(current_label); + get_current_menu_label(current_label, 255); case MENU_ACTION_SCAN: default: break; } { - strcpy(speak_string, ""); + strlcpy(speak_string, "",1); if (strcmp(title_name, "") != 0) { - strcpy(speak_string, title_name); - strcat(speak_string, " "); + strlcpy(speak_string, title_name, 255); + strlcat(speak_string, " ", 2); } - strcat(speak_string, current_label); + strlcat(speak_string, current_label, 255); if (strcmp(current_value, "...")!=0) { - strcat(speak_string, " "); - strcat(speak_string, current_value); + strlcat(speak_string, " ",2); + strlcat(speak_string, current_value, 255); } if (strcmp(speak_string, "") != 0) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 0e50f82d9f..9d621fec71 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -4130,7 +4130,7 @@ void menu_subsystem_populate(const struct retro_subsystem_info* subsystem, menu_ } -void get_current_menu_value(char* retstr) +void get_current_menu_value(char* retstr, size_t max) { const char* entry_label; menu_entry_t entry; @@ -4140,10 +4140,10 @@ void get_current_menu_value(char* retstr) menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); menu_entry_get_value(&entry, &entry_label); - strcpy(retstr, entry_label); + strlcpy(retstr, entry_label, max); } -void get_current_menu_label(char* retstr) +void get_current_menu_label(char* retstr, size_t max) { const char* entry_label; menu_entry_t entry; @@ -4153,10 +4153,10 @@ void get_current_menu_label(char* retstr) menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); menu_entry_get_rich_label(&entry, &entry_label); - strcpy(retstr, entry_label); + strlcpy(retstr, entry_label, max); } -void get_current_menu_sublabel(char* retstr) +void get_current_menu_sublabel(char* retstr, size_t max) { const char* entry_sublabel; menu_entry_t entry; @@ -4166,5 +4166,5 @@ void get_current_menu_sublabel(char* retstr) menu_entry_get(&entry, 0, menu_navigation_get_selection(), NULL, true); menu_entry_get_sublabel(&entry, &entry_sublabel); - strcpy(retstr, entry_sublabel); + strlcpy(retstr, entry_sublabel, max); } diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 4db32ca792..e6aa492e3d 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -281,9 +281,9 @@ int menu_entry_action( void menu_entry_init(menu_entry_t *entry); -void get_current_menu_value(char* retstr); -void get_current_menu_label(char* retstr); -void get_current_menu_sublabel(char* retstr); +void get_current_menu_value(char* retstr, size_t max); +void get_current_menu_label(char* retstr, size_t max); +void get_current_menu_sublabel(char* retstr, size_t max); RETRO_END_DECLS diff --git a/retroarch.c b/retroarch.c index cbf36ba8d3..7abd71f8cb 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4172,7 +4172,7 @@ static void handle_translation_cb( if (string_is_equal(error_string, "No text found.")) { RARCH_LOG("No text found...\n"); - strcpy(text_string, error_string); + strlcpy(text_string, error_string, 15); #ifdef HAVE_MENU_WIDGETS if (menu_widgets_paused) { @@ -29280,8 +29280,13 @@ bool accessibility_speak_linux(char* speak_text, const char* language, int prior { int pid; char* voice_out = malloc(3+strlen(language)); - strcpy(voice_out, "-v"); - strcat(voice_out, language); + char* speed_out = malloc(3+3); + + strlcpy(voice_out, "-v", 3); + strlcat(voice_out, language, 5); + + strlcpy(speed_out, "-s450", 6); + if (priority < 10 && speak_pid > 0) { /* check if old pid is running */ @@ -29314,7 +29319,7 @@ bool accessibility_speak_linux(char* speak_text, const char* language, int prior else { /* child process: replace process with the espeak command */ - execvp("espeak", (char* []) {"espeak", voice_out, speak_text, NULL}); + execvp("espeak", (char* []) {"espeak", voice_out,speed_out, speak_text, NULL}); } return true; } diff --git a/retroarch.h b/retroarch.h index 6fa5f73707..6a27f64479 100644 --- a/retroarch.h +++ b/retroarch.h @@ -2022,23 +2022,23 @@ unsigned int retroarch_get_rotation(void); RETRO_END_DECLS -bool is_input_keyboard_display_on(); -bool is_accessibility_enabled(); +bool is_input_keyboard_display_on(void); +bool is_accessibility_enabled(void); bool accessibility_speak(char* speak_text); bool accessibility_speak_priority(char* speak_text, int priority); -bool accessibility_startup_message(); +bool accessibility_startup_message(void); -bool is_narrator_running(); +bool is_narrator_running(void); #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) -bool is_narrator_running_windows(); +bool is_narrator_running_windows(void); bool accessibility_speak_windows(char* speak_text, const char* voice, int priority); #elif defined(__APPLE__) && defined(__MACH__) -bool is_narrator_running_macos(); +bool is_narrator_running_macos(void); char* accessibility_mac_language_code(const char* language); bool accessibility_speak_macos(char* speak_text, const char* voice, int priority); #elif defined(__linux__) || defined(__unix__) -bool is_narrator_running_linux(); +bool is_narrator_running_linux(void); bool accessibility_speak_linux(char* speak_text, const char* voice, int priority); #endif bool accessibility_speak_ai_service(char* speak_text, const char* voice, int priority);