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

@ -325,8 +325,8 @@ void read_color_theme_file(void) {
if (!global_settings.colors_file[0] || global_settings.colors_file[0] == '-')
return;
fd = open_pathfmt(O_RDONLY, THEME_DIR "/%s.colours",
global_settings.colors_file);
fd = open_pathfmt(buffer, sizeof(buffer), O_RDONLY,
THEME_DIR "/%s.colours", global_settings.colors_file);
if (fd < 0)
return;
while (read_line(fd, buffer, MAX_PATH) > 0)
@ -365,10 +365,11 @@ void read_viewer_theme_file(void)
custom_filetype_icons[i] = filetypes[i].icon;
}
fd = open_pathfmt(O_RDONLY, "%s/%s.icons", ICON_DIR,
global_settings.viewers_icon_file);
fd = open_pathfmt(buffer, sizeof(buffer), O_RDONLY,
ICON_DIR "/%s.icons", global_settings.viewers_icon_file);
if (fd < 0)
return;
while (read_line(fd, buffer, MAX_PATH) > 0)
{
if (!settings_parseline(buffer, &ext, &icon))