Fix up CVE-2022-33099 patch

In addition to upstream commit
  42d40581dd919fb134c07027ca1ce0844c670daf,
also apply the subsequent fixup commit
  603b2c64add5fbf4b7343525cf109af0c7077695.

Merge that into the same patch file.

Resolves: #2137384
This commit is contained in:
Michal Domonkos 2022-10-25 09:30:31 +02:00
parent 1ca1af29d2
commit 371139c976
2 changed files with 24 additions and 10 deletions

View File

@ -1,6 +1,6 @@
diff -up lua-5.4.2/src/ldebug.c.xyz lua-5.4.2/src/ldebug.c
--- lua-5.4.2/src/ldebug.c.xyz 2022-10-11 16:02:25.015408150 +0300
+++ lua-5.4.2/src/ldebug.c 2022-10-11 16:03:10.455804559 +0300
diff -up lua-5.4.2/src/ldebug.c.orig lua-5.4.2/src/ldebug.c
--- lua-5.4.2/src/ldebug.c.orig 2020-11-13 16:32:00.000000000 +0100
+++ lua-5.4.2/src/ldebug.c 2022-10-21 14:35:02.200941813 +0200
@@ -772,8 +772,11 @@ l_noret luaG_runerror (lua_State *L, con
va_start(argp, fmt);
msg = luaO_pushvfstring(L, fmt, argp); /* format message */
@ -14,9 +14,18 @@ diff -up lua-5.4.2/src/ldebug.c.xyz lua-5.4.2/src/ldebug.c
luaG_errormsg(L);
}
diff -up lua-5.4.2/src/lvm.c.xyz lua-5.4.2/src/lvm.c
--- lua-5.4.2/src/lvm.c.xyz 2022-10-11 16:02:32.614474444 +0300
+++ lua-5.4.2/src/lvm.c 2022-10-11 16:04:32.063516541 +0300
diff -up lua-5.4.2/src/lvm.c.orig lua-5.4.2/src/lvm.c
--- lua-5.4.2/src/lvm.c.orig 2020-11-13 16:32:02.000000000 +0100
+++ lua-5.4.2/src/lvm.c 2022-10-21 14:35:31.713755890 +0200
@@ -641,7 +641,7 @@ void luaV_concat (lua_State *L, int tota
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? */
@@ -654,8 +654,10 @@ void luaV_concat (lua_State *L, int tota
/* collect total length and number of strings */
for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
@ -29,12 +38,14 @@ diff -up lua-5.4.2/src/lvm.c.xyz lua-5.4.2/src/lvm.c
tl += l;
}
if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */
@@ -670,7 +672,7 @@ void luaV_concat (lua_State *L, int tota
@@ -669,8 +671,8 @@ void luaV_concat (lua_State *L, int tota
}
setsvalue2s(L, top - n, ts); /* create result */
}
total -= n-1; /* got 'n' strings to create 1 new */
- total -= n-1; /* got 'n' strings to create 1 new */
- L->top -= n-1; /* popped 'n' strings and pushed one */
+ 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 */
}

View File

@ -14,7 +14,7 @@
Name: lua
Version: %{major_version}.2
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Powerful light-weight programming language
License: MIT
URL: http://www.lua.org/
@ -211,6 +211,9 @@ popd
%{_libdir}/*.a
%changelog
* Tue Oct 25 2022 Michal Domonkos <mdomonko@redhat.com> - 5.4.2-7
- Fix up CVE-2022-33099 patch
* Mon Oct 17 2022 Michal Domonkos <mdomonko@redhat.com> - 5.4.2-6
- Enable gating