salimma / rpms / lua

Forked from rpms/lua 3 years ago
Clone
c4db958
diff -up lua-5.4.0/src/ldebug.c.CVE-2020-24370 lua-5.4.0/src/ldebug.c
c4db958
--- lua-5.4.0/src/ldebug.c.CVE-2020-24370	2020-08-19 13:25:29.295135397 -0400
c4db958
+++ lua-5.4.0/src/ldebug.c	2020-08-19 13:25:35.012135113 -0400
c4db958
@@ -188,8 +188,8 @@ static const char *upvalname (const Prot
c4db958
 static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
c4db958
   if (clLvalue(s2v(ci->func))->p->is_vararg) {
c4db958
     int nextra = ci->u.l.nextraargs;
c4db958
-    if (n <= nextra) {
c4db958
-      *pos = ci->func - nextra + (n - 1);
c4db958
+    if (n >= -nextra) {  /* 'n' is negative */
c4db958
+      *pos = ci->func - nextra - (n + 1);
c4db958
       return "(vararg)";  /* generic name for any vararg */
c4db958
     }
c4db958
   }
c4db958
@@ -202,7 +202,7 @@ const char *luaG_findlocal (lua_State *L
c4db958
   const char *name = NULL;
c4db958
   if (isLua(ci)) {
c4db958
     if (n < 0)  /* access to vararg values? */
c4db958
-      return findvararg(ci, -n, pos);
c4db958
+      return findvararg(ci, n, pos);
c4db958
     else
c4db958
       name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
c4db958
   }