From 0488c310beae129dfa2b8bad62d3ec47ccb3be0a Mon Sep 17 00:00:00 2001 From: rwx403335 Date: Wed, 21 Sep 2022 15:39:50 +0800 Subject: [PATCH] bugfix with upstream patch (cherry picked from commit f616e38ed043b2d9d6b0e37506c901d632327a13) --- ...can-use-invalidated-pointer-to-stack.patch | 37 +++++++++++++++++++ lua.spec | 7 +++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 backport-luaV_concat-can-use-invalidated-pointer-to-stack.patch diff --git a/backport-luaV_concat-can-use-invalidated-pointer-to-stack.patch b/backport-luaV_concat-can-use-invalidated-pointer-to-stack.patch new file mode 100644 index 0000000..beef7e6 --- /dev/null +++ b/backport-luaV_concat-can-use-invalidated-pointer-to-stack.patch @@ -0,0 +1,37 @@ +From 603b2c64add5fbf4b7343525cf109af0c7077695 Mon Sep 17 00:00:00 2001 +From: Roberto Ierusalimschy +Date: Mon, 23 May 2022 17:50:47 -0300 +Subject: [PATCH] 'luaV_concat' can use invalidated pointer to stack + +Bug introduced in commit 42d40581. +--- + src/lvm.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/lvm.c b/src/lvm.c +index cd992aa..614df05 100644 +--- a/src/lvm.c ++++ b/src/lvm.c +@@ -643,7 +643,7 @@ void luaV_concat (lua_State *L, int total) { + int n = 2; /* number of elements handled in this pass (at least 2) */ + if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) || + !tostring(L, s2v(top - 1))) +- luaT_tryconcatTM(L); ++ luaT_tryconcatTM(L); /* may invalidate 'top' */ + else if (isemptystr(s2v(top - 1))) /* second operand is empty? */ + cast_void(tostring(L, s2v(top - 2))); /* result is first operand */ + else if (isemptystr(s2v(top - 2))) { /* first operand is empty string? */ +@@ -673,8 +673,8 @@ void luaV_concat (lua_State *L, int total) { + } + setsvalue2s(L, top - n, ts); /* create result */ + } +- total -= n-1; /* got 'n' strings to create 1 new */ +- L->top = top - (n - 1); /* popped 'n' strings and pushed one */ ++ total -= n - 1; /* got 'n' strings to create one new */ ++ L->top -= n - 1; /* popped 'n' strings and pushed one */ + } while (total > 1); /* repeat until only 1 result left */ + } + +-- +1.8.3.1 + diff --git a/lua.spec b/lua.spec index 85fe925..7989b1a 100644 --- a/lua.spec +++ b/lua.spec @@ -6,7 +6,7 @@ Name: lua Version: 5.4.3 -Release: 8 +Release: 9 Summary: A powerful, efficient, lightweight, embeddable scripting language License: MIT URL: http://www.lua.org/ @@ -28,6 +28,7 @@ Patch6001: backport-CVE-2021-44647.patch Patch6002: backport-CVE-2022-28805.patch Patch6003: backport-CVE-2022-33099.patch Patch6004: backport-CVE-2021-44964.patch +Patch6005: backport-luaV_concat-can-use-invalidated-pointer-to-stack.patch BuildRequires: automake autoconf libtool readline-devel ncurses-devel @@ -65,6 +66,7 @@ mv src/luaconf.h src/luaconf.h.template.in %patch6002 -p1 %patch6003 -p1 %patch6004 -p1 +%patch6005 -p1 # Put proper version in configure.ac, patch0 hardcodes 5.3.0 sed -i 's|5.3.0|%{version}|g' configure.ac @@ -139,6 +141,9 @@ LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{_libdir} $RPM_BUILD_ROOT/%{_bindir}/lua -e"_U= %{_mandir}/man1/lua*.1* %changelog +* Wed Sep 21 2022 renhongxun - 5.4.3-9 +- bugfix with upstream patch + * Fri Aug 19 2022 shixuantong - 5.4.3-8 - fix CVE-2021-44964