From 3745c813f924b12232c4f37610aecd23fe5654b8 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Wed, 23 Nov 2022 21:46:13 -0500 Subject: 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 --- apps/filetypes.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'apps/filetypes.c') diff --git a/apps/filetypes.c b/apps/filetypes.c index d690b554fd..ec9bd1a7ae 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -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)) -- cgit v1.2.3