Skip to content

Commit

Permalink
Backport CVE-2020-24370's patch
Browse files Browse the repository at this point in the history
Signed-off-by: ChenHao Lu <[email protected]>
  • Loading branch information
the-Chain-Warden-thresh committed Feb 2, 2024
1 parent 2e6b3c4 commit 682eea2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions module/lua/ldebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ static const char *upvalname (Proto *p, int uv) {

static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
int nparams = clLvalue(ci->func)->p->numparams;
if (n >= ci->u.l.base - ci->func - nparams)
int nvararg = cast_int(ci->u.l.base - ci->func) - nparams;
if (n <= -nvararg)
return NULL; /* no such vararg */
else {
*pos = ci->func + nparams + n;
*pos = ci->func + nparams - n;
return "(*vararg)"; /* generic name for any vararg */
}
}
Expand All @@ -126,7 +127,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
StkId base;
if (isLua(ci)) {
if (n < 0) /* access to vararg values? */
return findvararg(ci, -n, pos);
return findvararg(ci, n, pos);
else {
base = ci->u.l.base;
name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
Expand Down

0 comments on commit 682eea2

Please sign in to comment.