mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Fixes #4839: path buffer overflow if LUA widget or theme directory name was too long (max length of directory name is 13 characters) (#4876)
This commit is contained in:
parent
c1e7235375
commit
582546f8ed
1 changed files with 4 additions and 2 deletions
|
@ -31,6 +31,7 @@
|
|||
lua_State *lsWidgets = NULL;
|
||||
extern int custom_lua_atpanic(lua_State *L);
|
||||
|
||||
#define LUA_WIDGET_FILENAME "/main.lua"
|
||||
#define LUA_FULLPATH_MAXLEN (LEN_FILE_PATH_MAX + LEN_SCRIPT_FILENAME + LEN_FILE_EXTENSION_MAX) // max length (example: /SCRIPTS/THEMES/mytheme.lua)
|
||||
|
||||
void exec(int function, int nresults=0)
|
||||
|
@ -496,9 +497,10 @@ void luaLoadFiles(const char * directory, void (*callback)())
|
|||
res = f_readdir(&dir, &fno); /* Read a directory item */
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
|
||||
uint8_t len = strlen(fno.fname);
|
||||
if (len > 0 && fno.fname[0]!='.' && (fno.fattrib & AM_DIR)) {
|
||||
if (len > 0 && (unsigned int)(len + pathlen + sizeof(LUA_WIDGET_FILENAME)) <= sizeof(path) &&
|
||||
fno.fname[0]!='.' && (fno.fattrib & AM_DIR)) {
|
||||
strcpy(&path[pathlen], fno.fname);
|
||||
strcat(&path[pathlen], "/main.lua");
|
||||
strcat(&path[pathlen], LUA_WIDGET_FILENAME);
|
||||
if (isFileAvailable(path)) {
|
||||
luaLoadFile(path, callback);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue