syslinux/backport-CVE-2020-24370.patch
lingsheng fefd22e263 fix CVE-2020-24370
(cherry picked from commit 63f384c0a82a36aec9540f980226692e3d40ec2f)
2025-03-12 10:43:55 +08:00

37 lines
1.3 KiB
Diff

From b5bc89846721375fe30772eb8c5ab2786f362bf9 Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 3 Aug 2020 16:25:28 -0300
Subject: [PATCH] Fixed bug: Negation overflow in getlocal/setlocal
---
com32/lua/src/ldebug.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/com32/lua/src/ldebug.c b/com32/lua/src/ldebug.c
index e1389296e..bb0e1d4ac 100644
--- a/com32/lua/src/ldebug.c
+++ b/com32/lua/src/ldebug.c
@@ -133,10 +133,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 = 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 */
}
}
@@ -148,7 +149,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));