Limit path length passed to C library loader.

This commit is contained in:
Mike Pall 2020-09-05 20:02:54 +02:00
parent e296f56b82
commit 90e65514dd

View File

@ -208,7 +208,12 @@ static const char *mksymname(lua_State *L, const char *modname,
static int ll_loadfunc(lua_State *L, const char *path, const char *name, int r)
{
void **reg = ll_register(L, path);
void **reg;
if (strlen(path) >= 4096) {
lua_pushliteral(L, "path too long");
return PACKAGE_ERR_LIB;
}
reg = ll_register(L, path);
if (*reg == NULL) *reg = ll_load(L, path, (*name == '*'));
if (*reg == NULL) {
return PACKAGE_ERR_LIB; /* Unable to load library. */