summaryrefslogtreecommitdiff
path: root/apps/talk.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/talk.c')
-rw-r--r--apps/talk.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 65933c6895..777c0f5a01 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -810,8 +810,8 @@ void talk_init(void)
810 talk_force_shutup(); /* In case we have something speaking! */ 810 talk_force_shutup(); /* In case we have something speaking! */
811 811
812 talk_initialized = true; 812 talk_initialized = true;
813 strlcpy((char *)last_lang, (char *)global_settings.lang_file, 813 strmemccpy((char *)last_lang, (char *)global_settings.lang_file,
814 MAX_FILENAME); 814 MAX_FILENAME);
815 815
816 /* reset some states */ 816 /* reset some states */
817 queue_write = queue_read = 0; /* reset the queue */ 817 queue_write = queue_read = 0; /* reset the queue */
@@ -1066,14 +1066,21 @@ static int talk_spell_basename(const char *path,
1066 } 1066 }
1067 char buf[MAX_PATH]; 1067 char buf[MAX_PATH];
1068 /* Spell only the path component after the last slash */ 1068 /* Spell only the path component after the last slash */
1069 strlcpy(buf, path, sizeof(buf)); 1069 char *end = strmemccpy(buf, path, sizeof(buf));
1070 if(strlen(buf) >1 && buf[strlen(buf)-1] == '/') 1070
1071 /* strip trailing slash */ 1071 if (!end)
1072 buf[strlen(buf)-1] = '\0'; 1072 return 0;
1073
1074 size_t len = end - buf - 1;
1075 if(len >1 && buf[len-1] == '/')
1076 buf[--len] = '\0'; /* strip trailing slash */
1077
1073 char *ptr = strrchr(buf, '/'); 1078 char *ptr = strrchr(buf, '/');
1074 if(ptr && strlen(buf) >1) 1079 if(ptr && len >1)
1075 ++ptr; 1080 ++ptr;
1076 else ptr = buf; 1081 else
1082 ptr = buf;
1083
1077 return talk_spell(ptr, enqueue); 1084 return talk_spell(ptr, enqueue);
1078} 1085}
1079 1086
@@ -1122,7 +1129,7 @@ int talk_fullpath(const char* path, bool enqueue)
1122 return talk_spell(path, true); 1129 return talk_spell(path, true);
1123 talk_id(VOICE_CHAR_SLASH, true); 1130 talk_id(VOICE_CHAR_SLASH, true);
1124 char buf[MAX_PATH]; 1131 char buf[MAX_PATH];
1125 strlcpy(buf, path, MAX_PATH); 1132 strmemccpy(buf, path, MAX_PATH);
1126 char *start = buf+1; /* start of current component */ 1133 char *start = buf+1; /* start of current component */
1127 char *ptr = strchr(start, '/'); /* end of current component */ 1134 char *ptr = strchr(start, '/'); /* end of current component */
1128 while(ptr) { /* There are more slashes ahead */ 1135 while(ptr) { /* There are more slashes ahead */
@@ -1636,7 +1643,7 @@ bool talk_get_debug_data(struct talk_debug_data *data)
1636 if (global_settings.lang_file[0] && global_settings.lang_file[0] != 0xff) 1643 if (global_settings.lang_file[0] && global_settings.lang_file[0] != 0xff)
1637 p_lang = (char *)global_settings.lang_file; 1644 p_lang = (char *)global_settings.lang_file;
1638 1645
1639 strlcpy(data->voicefile, p_lang, sizeof(data->voicefile)); 1646 strmemccpy(data->voicefile, p_lang, sizeof(data->voicefile));
1640 1647
1641 if (!has_voicefile || index_handle <= 0) 1648 if (!has_voicefile || index_handle <= 0)
1642 { 1649 {