From c64a3e7596b9e29c58a0a7cdd6574a837e0395e5 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Sun, 28 May 2017 13:47:18 +0200 Subject: luaL_loadfilex raise error if filename is not a file e.g. a directory --- src/lauxlib.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lauxlib.js b/src/lauxlib.js index 3851ee7..c6a975c 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -745,6 +745,8 @@ if (!WEB) { lua.lua_pushliteral(L, `@${jsfilename}`); try { lf.f = fs.openSync(jsfilename, "r"); + if (!fs.fstatSync(lf.f).isFile()) + throw new Error(`${jsfilename} is not a readable file`); } catch (e) { return errfile(L, "open", fnameindex, e); } -- cgit v1.2.3-70-g09d2