diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-11-23 21:46:13 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2022-11-23 22:09:46 -0500 |
commit | 3745c813f924b12232c4f37610aecd23fe5654b8 (patch) | |
tree | 41069cc3f39c61b7d0611877d4251827be6cd2e1 /apps/misc.c | |
parent | 80b8b13544c79f57bf7da6320cee5d76c162e96c (diff) | |
download | rockbox-3745c813f924b12232c4f37610aecd23fe5654b8.tar.gz rockbox-3745c813f924b12232c4f37610aecd23fe5654b8.zip |
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
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 5 |
1 files changed, 2 insertions, 3 deletions
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 | |||
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | /* open but with a builtin printf for assembling the path */ | 1421 | /* open but with a builtin printf for assembling the path */ |
1422 | int open_pathfmt(int oflag, const char *pathfmt, ...) | 1422 | int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...) |
1423 | { | 1423 | { |
1424 | static char buf[MAX_PATH]; | ||
1425 | va_list ap; | 1424 | va_list ap; |
1426 | va_start(ap, pathfmt); | 1425 | va_start(ap, pathfmt); |
1427 | vsnprintf(buf, sizeof(buf), pathfmt, ap); | 1426 | vsnprintf(buf, size, pathfmt, ap); |
1428 | va_end(ap); | 1427 | va_end(ap); |
1429 | return open(buf, oflag, 0666); | 1428 | return open(buf, oflag, 0666); |
1430 | } | 1429 | } |