lib: Prevent possible memory overwrite

fname is MAXPATHLEN and scriptdir and fs->name are less then
MAXPATHLEN but the combination of those two + the `.lua` are
greater than the MAXPATHLEN.  Just give us more room to prevent
a coding boo boo.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2021-01-24 07:52:55 -05:00
parent 8f17f6eb2d
commit 833c1f9fd1

View File

@ -208,7 +208,7 @@ struct frrscript *frrscript_load(const char *name,
fs->L = luaL_newstate();
frrlua_export_logging(fs->L);
char fname[MAXPATHLEN];
char fname[MAXPATHLEN * 2];
snprintf(fname, sizeof(fname), "%s/%s.lua", scriptdir, fs->name);
int ret = luaL_loadfile(fs->L, fname);