forked from len0rd/rockbox
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:
parent
80b8b13544
commit
3745c813f9
9 changed files with 34 additions and 27 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue