misc.c open_pathfmt caller supplied buffer

Amachronic raised concern about open() blocking causing a static buf
to get overwritten in multiple calls its prudent to just have the caller
supply the buffer to minimize stack issues later

Change-Id: Iae27c7d063adb1a65688f920f6aa5c395fa5694a
This commit is contained in:
William Wilgus 2022-11-23 21:46:13 -05:00
parent 80b8b13544
commit 3745c813f9
9 changed files with 34 additions and 27 deletions

View file

@ -247,6 +247,7 @@ static struct buflib_callbacks talk_ops = {
static int open_voicefile(void)
{
char fname[MAX_PATH];
char* p_lang = DEFAULT_VOICE_LANG; /* default */
if ( global_settings.lang_file[0] &&
@ -255,7 +256,8 @@ static int open_voicefile(void)
p_lang = (char *)global_settings.lang_file;
}
return open_pathfmt(O_RDONLY, LANG_DIR "/%s.voice", p_lang);
return open_pathfmt(fname, sizeof(fname),
O_RDONLY, LANG_DIR "/%s.voice", p_lang);
}