nmap/backport-Bug-Lua-can-generate-wrong-code-when-_ENV-is-const.patch
xingwei bfea188fea backport lua upstream patch to fix CVE-2022-28805
(cherry picked from commit 61dc4d0f9c9bc41a0f614a7fe92ddba8bdefd45e)
2025-01-16 10:09:08 +08:00

26 lines
1019 B
Diff

From 1f3c6f4534c6411313361697d98d1145a1f030fa Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 15 Feb 2022 12:28:46 -0300
Subject: [PATCH] Bug: Lua can generate wrong code when _ENV is <const>
Conflict: remove testes/attrib.lua and adapt lparser.c file directory
Reference: https://github.com/lua/lua/commit/1f3c6f4534c6411313361697d98d1145a1f030fa
---
liblua/lparser.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/liblua/lparser.c b/liblua/lparser.c
index 3abe3d7..a5cd552 100644
--- a/liblua/lparser.c
+++ b/liblua/lparser.c
@@ -468,6 +468,7 @@ static void singlevar (LexState *ls, expdesc *var) {
expdesc key;
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
lua_assert(var->k != VVOID); /* this one must exist */
+ luaK_exp2anyregup(fs, var); /* but could be a constant */
codestring(&key, varname); /* key is variable name */
luaK_indexed(fs, var, &key); /* env[varname] */
}
--
2.43.0