]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Prevent possible memory overwrite
authorDonald Sharp <sharpd@nvidia.com>
Sun, 24 Jan 2021 12:52:55 +0000 (07:52 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 25 Jan 2021 14:15:36 +0000 (09:15 -0500)
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>
lib/frrscript.c

index a3de474a4e9cb068a0fe3adade919e61c2b8d12a..a43f389f99760ce46caf90fa23bb58b20b309784 100644 (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);