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/misc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apps/misc.c') diff --git a/apps/misc.c b/apps/misc.c index e2913d53b3..eb821548fe 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -1419,12 +1419,11 @@ int string_option(const char *option, const char *const oplist[], bool ignore_ca } /* open but with a builtin printf for assembling the path */ -int open_pathfmt(int oflag, const char *pathfmt, ...) +int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...) { - static char buf[MAX_PATH]; va_list ap; va_start(ap, pathfmt); - vsnprintf(buf, sizeof(buf), pathfmt, ap); + vsnprintf(buf, size, pathfmt, ap); va_end(ap); return open(buf, oflag, 0666); } -- cgit v1.2.3