From 833c1f9fd14c4764b9f36f5e61c57130ff4f7118 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sun, 24 Jan 2021 07:52:55 -0500 Subject: [PATCH] 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 --- lib/frrscript.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/frrscript.c b/lib/frrscript.c index a3de474a4e..a43f389f99 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -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);