Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f08586b17f | ||
|
b831eb6988 | ||
|
7dabd5ee69 | ||
|
8dad25e9a4 | ||
|
fd3a8e4b75 | ||
|
0adfa0746e | ||
|
8050c843bd | ||
|
fd778929eb | ||
|
e86927ce21 | ||
|
786a69eca4 | ||
|
0c7ff179d8 | ||
|
96be13d24e | ||
|
058dca212c | ||
|
dc3e772ee9 | ||
|
54c3992cf5 | ||
|
da74cc970e | ||
|
4b02202aa0 | ||
|
3e03dd9b69 | ||
|
23a9922b41 | ||
|
a178517865 | ||
|
fae2e38de7 | ||
|
4b399374b6 | ||
|
a043d07614 | ||
|
c4db958ec0 | ||
|
0439a5e58a | ||
|
b9107ac261 | ||
|
f8bc6d8ddc | ||
|
6b90d8ec0b | ||
|
ab3d82cbb9 | ||
|
18ba6592c3 | ||
|
627e03f462 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -14,3 +14,14 @@ lua-5.1.4/
|
|||||||
/lua-5.3.4.tar.gz
|
/lua-5.3.4.tar.gz
|
||||||
/lua-5.3.4-tests.tar.gz
|
/lua-5.3.4-tests.tar.gz
|
||||||
/lua-5.3.5.tar.gz
|
/lua-5.3.5.tar.gz
|
||||||
|
/lua-5.4.0.tar.gz
|
||||||
|
/lua-5.4.0-tests.tar.gz
|
||||||
|
/lua-5.4.1-tests.tar.gz
|
||||||
|
/lua-5.4.1.tar.gz
|
||||||
|
/lua-5.4.2.tar.gz
|
||||||
|
/lua-5.4.2-tests.tar.gz
|
||||||
|
/lua-5.4.3.tar.gz
|
||||||
|
/lua-5.4.3-tests.tar.gz
|
||||||
|
/lua-5.4.4.tar.gz
|
||||||
|
/lua-5.4.4-tests.tar.gz
|
||||||
|
/lua-5.3.6.tar.gz
|
||||||
|
140
196bb94d66e727e0aec053a0276c3ad701500762.patch
Normal file
140
196bb94d66e727e0aec053a0276c3ad701500762.patch
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
From 196bb94d66e727e0aec053a0276c3ad701500762 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
|
||||||
|
Date: Wed, 25 May 2022 17:41:39 -0300
|
||||||
|
Subject: [PATCH] Bug: 'lua_settop' may use an invalid pointer to stack
|
||||||
|
|
||||||
|
---
|
||||||
|
lapi.c | 5 ++---
|
||||||
|
ldo.c | 12 ++++++------
|
||||||
|
lfunc.c | 5 +++--
|
||||||
|
lfunc.h | 2 +-
|
||||||
|
testes/locals.lua | 22 ++++++++++++++++++++++
|
||||||
|
5 files changed, 34 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lapi.c b/lapi.c
|
||||||
|
index 352a385a3..5833c7b0a 100644
|
||||||
|
--- a/src/lapi.c
|
||||||
|
+++ b/src/lapi.c
|
||||||
|
@@ -197,7 +197,7 @@ LUA_API void lua_settop (lua_State *L, int idx) {
|
||||||
|
newtop = L->top + diff;
|
||||||
|
if (diff < 0 && L->tbclist >= newtop) {
|
||||||
|
lua_assert(hastocloseCfunc(ci->nresults));
|
||||||
|
- luaF_close(L, newtop, CLOSEKTOP, 0);
|
||||||
|
+ newtop = luaF_close(L, newtop, CLOSEKTOP, 0);
|
||||||
|
}
|
||||||
|
L->top = newtop; /* correct top only after closing any upvalue */
|
||||||
|
lua_unlock(L);
|
||||||
|
@@ -210,8 +210,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) {
|
||||||
|
level = index2stack(L, idx);
|
||||||
|
api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist == level,
|
||||||
|
"no variable to close at given level");
|
||||||
|
- luaF_close(L, level, CLOSEKTOP, 0);
|
||||||
|
- level = index2stack(L, idx); /* stack may be moved */
|
||||||
|
+ level = luaF_close(L, level, CLOSEKTOP, 0);
|
||||||
|
setnilvalue(s2v(level));
|
||||||
|
lua_unlock(L);
|
||||||
|
}
|
||||||
|
diff --git a/ldo.c b/ldo.c
|
||||||
|
index 5aa6d59d4..13498905f 100644
|
||||||
|
--- a/src/ldo.c
|
||||||
|
+++ b/src/ldo.c
|
||||||
|
@@ -430,14 +430,15 @@ l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) {
|
||||||
|
break;
|
||||||
|
default: /* two/more results and/or to-be-closed variables */
|
||||||
|
if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */
|
||||||
|
- ptrdiff_t savedres = savestack(L, res);
|
||||||
|
L->ci->callstatus |= CIST_CLSRET; /* in case of yields */
|
||||||
|
L->ci->u2.nres = nres;
|
||||||
|
- luaF_close(L, res, CLOSEKTOP, 1);
|
||||||
|
+ res = luaF_close(L, res, CLOSEKTOP, 1);
|
||||||
|
L->ci->callstatus &= ~CIST_CLSRET;
|
||||||
|
- if (L->hookmask) /* if needed, call hook after '__close's */
|
||||||
|
+ if (L->hookmask) { /* if needed, call hook after '__close's */
|
||||||
|
+ ptrdiff_t savedres = savestack(L, res);
|
||||||
|
rethook(L, L->ci, nres);
|
||||||
|
- res = restorestack(L, savedres); /* close and hook can move stack */
|
||||||
|
+ res = restorestack(L, savedres); /* hook can move stack */
|
||||||
|
+ }
|
||||||
|
wanted = decodeNresults(wanted);
|
||||||
|
if (wanted == LUA_MULTRET)
|
||||||
|
wanted = nres; /* we want all results */
|
||||||
|
@@ -654,8 +655,7 @@ static int finishpcallk (lua_State *L, CallInfo *ci) {
|
||||||
|
else { /* error */
|
||||||
|
StkId func = restorestack(L, ci->u2.funcidx);
|
||||||
|
L->allowhook = getoah(ci->callstatus); /* restore 'allowhook' */
|
||||||
|
- luaF_close(L, func, status, 1); /* can yield or raise an error */
|
||||||
|
- func = restorestack(L, ci->u2.funcidx); /* stack may be moved */
|
||||||
|
+ func = luaF_close(L, func, status, 1); /* can yield or raise an error */
|
||||||
|
luaD_seterrorobj(L, status, func);
|
||||||
|
luaD_shrinkstack(L); /* restore stack size in case of overflow */
|
||||||
|
setcistrecst(ci, LUA_OK); /* clear original status */
|
||||||
|
diff --git a/lfunc.c b/lfunc.c
|
||||||
|
index f5889a21d..3ed65de2b 100644
|
||||||
|
--- a/src/lfunc.c
|
||||||
|
+++ b/src/lfunc.c
|
||||||
|
@@ -223,9 +223,9 @@ static void poptbclist (lua_State *L) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Close all upvalues and to-be-closed variables up to the given stack
|
||||||
|
-** level.
|
||||||
|
+** level. Return restored 'level'.
|
||||||
|
*/
|
||||||
|
-void luaF_close (lua_State *L, StkId level, int status, int yy) {
|
||||||
|
+StkId luaF_close (lua_State *L, StkId level, int status, int yy) {
|
||||||
|
ptrdiff_t levelrel = savestack(L, level);
|
||||||
|
luaF_closeupval(L, level); /* first, close the upvalues */
|
||||||
|
while (L->tbclist >= level) { /* traverse tbc's down to that level */
|
||||||
|
@@ -234,6 +234,7 @@ void luaF_close (lua_State *L, StkId level, int status, int yy) {
|
||||||
|
prepcallclosemth(L, tbc, status, yy); /* close variable */
|
||||||
|
level = restorestack(L, levelrel);
|
||||||
|
}
|
||||||
|
+ return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/lfunc.h b/lfunc.h
|
||||||
|
index dc1cebccd..3d296971e 100644
|
||||||
|
--- a/src/lfunc.h
|
||||||
|
+++ b/src/lfunc.h
|
||||||
|
@@ -54,7 +54,7 @@ LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
|
||||||
|
LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
|
||||||
|
LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level);
|
||||||
|
LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level);
|
||||||
|
-LUAI_FUNC void luaF_close (lua_State *L, StkId level, int status, int yy);
|
||||||
|
+LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, int status, int yy);
|
||||||
|
LUAI_FUNC void luaF_unlinkupval (UpVal *uv);
|
||||||
|
LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
|
||||||
|
LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
|
||||||
|
diff --git a/testes/locals.lua b/testes/locals.lua
|
||||||
|
index 62a88df57..ddb75054f 100644
|
||||||
|
--- a/lua-5.4.4-tests/locals.lua
|
||||||
|
+++ b/lua-5.4.4-tests/locals.lua
|
||||||
|
@@ -592,6 +592,28 @@ end
|
||||||
|
|
||||||
|
if rawget(_G, "T") then
|
||||||
|
|
||||||
|
+ do
|
||||||
|
+ -- bug in 5.4.3
|
||||||
|
+ -- 'lua_settop' may use a pointer to stack invalidated by 'luaF_close'
|
||||||
|
+
|
||||||
|
+ -- reduce stack size
|
||||||
|
+ collectgarbage(); collectgarbage(); collectgarbage()
|
||||||
|
+
|
||||||
|
+ -- force a stack reallocation
|
||||||
|
+ local function loop (n)
|
||||||
|
+ if n < 400 then loop(n + 1) end
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ -- close metamethod will reallocate the stack
|
||||||
|
+ local o = setmetatable({}, {__close = function () loop(0) end})
|
||||||
|
+
|
||||||
|
+ local script = [[toclose 2; settop 1; return 1]]
|
||||||
|
+
|
||||||
|
+ assert(T.testC(script, o) == script)
|
||||||
|
+
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+
|
||||||
|
-- memory error inside closing function
|
||||||
|
local function foo ()
|
||||||
|
local y <close> = func2close(function () T.alloccount() end)
|
43
1f3c6f4534c6411313361697d98d1145a1f030fa.patch
Normal file
43
1f3c6f4534c6411313361697d98d1145a1f030fa.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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>
|
||||||
|
|
||||||
|
---
|
||||||
|
lparser.c | 1 +
|
||||||
|
testes/attrib.lua | 10 ++++++++++
|
||||||
|
2 files changed, 11 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/lparser.c b/lparser.c
|
||||||
|
index 3abe3d751..a5cd55257 100644
|
||||||
|
--- a/src/lparser.c
|
||||||
|
+++ b/src/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] */
|
||||||
|
}
|
||||||
|
diff --git a/testes/attrib.lua b/testes/attrib.lua
|
||||||
|
index b1076c768..83821c069 100644
|
||||||
|
--- lua-5.4.4/lua-5.4.4-tests/attrib.lua
|
||||||
|
+++ lua-5.4.4/lua-5.4.4-tests/attrib.lua
|
||||||
|
@@ -434,6 +434,16 @@ a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 ==
|
||||||
|
10)
|
||||||
|
|
||||||
|
|
||||||
|
+do
|
||||||
|
+ -- _ENV constant
|
||||||
|
+ local function foo ()
|
||||||
|
+ local _ENV <const> = 11
|
||||||
|
+ X = "hi"
|
||||||
|
+ end
|
||||||
|
+ local st, msg = pcall(foo)
|
||||||
|
+ assert(not st and string.find(msg, "number"))
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
|
||||||
|
-- test of large float/integer indices
|
||||||
|
|
94
25b143dd34fb587d1e35290c4b25bc08954800e2.patch
Normal file
94
25b143dd34fb587d1e35290c4b25bc08954800e2.patch
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
From 25b143dd34fb587d1e35290c4b25bc08954800e2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
|
||||||
|
Date: Mon, 7 Feb 2022 10:16:35 -0300
|
||||||
|
Subject: [PATCH] Bug: lua.c assumes that argv has at least one element
|
||||||
|
|
||||||
|
---
|
||||||
|
lua.c | 35 +++++++++++++++++++++++------------
|
||||||
|
1 file changed, 23 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lua.c b/lua.c
|
||||||
|
index 0f1900444..7f7dc2b22 100644
|
||||||
|
--- a/src/lua.c
|
||||||
|
+++ b/src/lua.c
|
||||||
|
@@ -177,10 +177,11 @@ static void print_version (void) {
|
||||||
|
** to the script (everything after 'script') go to positive indices;
|
||||||
|
** other arguments (before the script name) go to negative indices.
|
||||||
|
** If there is no script name, assume interpreter's name as base.
|
||||||
|
+** (If there is no interpreter's name either, 'script' is -1, so
|
||||||
|
+** table sizes are zero.)
|
||||||
|
*/
|
||||||
|
static void createargtable (lua_State *L, char **argv, int argc, int script) {
|
||||||
|
int i, narg;
|
||||||
|
- if (script == argc) script = 0; /* no script name? */
|
||||||
|
narg = argc - (script + 1); /* number of positive indices */
|
||||||
|
lua_createtable(L, narg, script + 1);
|
||||||
|
for (i = 0; i < argc; i++) {
|
||||||
|
@@ -268,14 +269,23 @@ static int handle_script (lua_State *L, char **argv) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Traverses all arguments from 'argv', returning a mask with those
|
||||||
|
-** needed before running any Lua code (or an error code if it finds
|
||||||
|
-** any invalid argument). 'first' returns the first not-handled argument
|
||||||
|
-** (either the script name or a bad argument in case of error).
|
||||||
|
+** needed before running any Lua code or an error code if it finds any
|
||||||
|
+** invalid argument. In case of error, 'first' is the index of the bad
|
||||||
|
+** argument. Otherwise, 'first' is -1 if there is no program name,
|
||||||
|
+** 0 if there is no script name, or the index of the script name.
|
||||||
|
*/
|
||||||
|
static int collectargs (char **argv, int *first) {
|
||||||
|
int args = 0;
|
||||||
|
int i;
|
||||||
|
- for (i = 1; argv[i] != NULL; i++) {
|
||||||
|
+ if (argv[0] != NULL) { /* is there a program name? */
|
||||||
|
+ if (argv[0][0]) /* not empty? */
|
||||||
|
+ progname = argv[0]; /* save it */
|
||||||
|
+ }
|
||||||
|
+ else { /* no program name */
|
||||||
|
+ *first = -1;
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ for (i = 1; argv[i] != NULL; i++) { /* handle arguments */
|
||||||
|
*first = i;
|
||||||
|
if (argv[i][0] != '-') /* not an option? */
|
||||||
|
return args; /* stop handling options */
|
||||||
|
@@ -316,7 +326,7 @@ static int collectargs (char **argv, int *first) {
|
||||||
|
return has_error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- *first = i; /* no script name */
|
||||||
|
+ *first = 0; /* no script name */
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -609,8 +619,8 @@ static int pmain (lua_State *L) {
|
||||||
|
char **argv = (char **)lua_touserdata(L, 2);
|
||||||
|
int script;
|
||||||
|
int args = collectargs(argv, &script);
|
||||||
|
+ int optlim = (script > 0) ? script : argc; /* first argv not an option */
|
||||||
|
luaL_checkversion(L); /* check that interpreter has correct version */
|
||||||
|
- if (argv[0] && argv[0][0]) progname = argv[0];
|
||||||
|
if (args == has_error) { /* bad arg? */
|
||||||
|
print_usage(argv[script]); /* 'script' has index of bad arg. */
|
||||||
|
return 0;
|
||||||
|
@@ -628,14 +638,15 @@ static int pmain (lua_State *L) {
|
||||||
|
if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */
|
||||||
|
return 0; /* error running LUA_INIT */
|
||||||
|
}
|
||||||
|
- if (!runargs(L, argv, script)) /* execute arguments -e and -l */
|
||||||
|
+ if (!runargs(L, argv, optlim)) /* execute arguments -e and -l */
|
||||||
|
return 0; /* something failed */
|
||||||
|
- if (script < argc && /* execute main script (if there is one) */
|
||||||
|
- handle_script(L, argv + script) != LUA_OK)
|
||||||
|
- return 0;
|
||||||
|
+ if (script > 0) { /* execute main script (if there is one) */
|
||||||
|
+ if (handle_script(L, argv + script) != LUA_OK)
|
||||||
|
+ return 0; /* interrupt in case of error */
|
||||||
|
+ }
|
||||||
|
if (args & has_i) /* -i option? */
|
||||||
|
doREPL(L); /* do read-eval-print loop */
|
||||||
|
- else if (script == argc && !(args & (has_e | has_v))) { /* no arguments? */
|
||||||
|
+ else if (script < 1 && !(args & (has_e | has_v))) { /* no active option? */
|
||||||
|
if (lua_stdin_is_tty()) { /* running in interactive mode? */
|
||||||
|
print_version();
|
||||||
|
doREPL(L); /* do read-eval-print loop */
|
59
42d40581dd919fb134c07027ca1ce0844c670daf.patch
Normal file
59
42d40581dd919fb134c07027ca1ce0844c670daf.patch
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
From 42d40581dd919fb134c07027ca1ce0844c670daf Mon Sep 17 00:00:00 2001
|
||||||
|
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
|
||||||
|
Date: Fri, 20 May 2022 13:14:33 -0300
|
||||||
|
Subject: [PATCH] Save stack space while handling errors
|
||||||
|
|
||||||
|
Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
|
||||||
|
and some errors can recur (e.g., string overflow while creating an
|
||||||
|
error message in 'luaG_runerror', or a C-stack overflow before calling
|
||||||
|
the message handler), the code should use stack slots with parsimony.
|
||||||
|
|
||||||
|
This commit fixes the bug "Lua-stack overflow when C stack overflows
|
||||||
|
while handling an error".
|
||||||
|
---
|
||||||
|
ldebug.c | 5 ++++-
|
||||||
|
lvm.c | 6 ++++--
|
||||||
|
2 files changed, 8 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/ldebug.c b/ldebug.c
|
||||||
|
index a716d95e2..fa15eaf68 100644
|
||||||
|
--- a/src/ldebug.c
|
||||||
|
+++ b/src/ldebug.c
|
||||||
|
@@ -824,8 +824,11 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
|
||||||
|
va_start(argp, fmt);
|
||||||
|
msg = luaO_pushvfstring(L, fmt, argp); /* format message */
|
||||||
|
va_end(argp);
|
||||||
|
- if (isLua(ci)) /* if Lua function, add source:line information */
|
||||||
|
+ if (isLua(ci)) { /* if Lua function, add source:line information */
|
||||||
|
luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
|
||||||
|
+ setobjs2s(L, L->top - 2, L->top - 1); /* remove 'msg' from the stack */
|
||||||
|
+ L->top--;
|
||||||
|
+ }
|
||||||
|
luaG_errormsg(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/lvm.c b/lvm.c
|
||||||
|
index e8c2e9627..cd992aada 100644
|
||||||
|
--- a/src/lvm.c
|
||||||
|
+++ b/src/lvm.c
|
||||||
|
@@ -656,8 +656,10 @@ void luaV_concat (lua_State *L, int total) {
|
||||||
|
/* collect total length and number of strings */
|
||||||
|
for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
|
||||||
|
size_t l = vslen(s2v(top - n - 1));
|
||||||
|
- if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl))
|
||||||
|
+ if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) {
|
||||||
|
+ L->top = top - total; /* pop strings to avoid wasting stack */
|
||||||
|
luaG_runerror(L, "string length overflow");
|
||||||
|
+ }
|
||||||
|
tl += l;
|
||||||
|
}
|
||||||
|
if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */
|
||||||
|
@@ -672,7 +674,7 @@ 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 -= n-1; /* popped 'n' strings and pushed one */
|
||||||
|
+ L->top = top - (n - 1); /* popped 'n' strings and pushed one */
|
||||||
|
} while (total > 1); /* repeat until only 1 result left */
|
||||||
|
}
|
||||||
|
|
123
c764ca71a639f5585b5f466bea25dc42b855a4b0.patch
Normal file
123
c764ca71a639f5585b5f466bea25dc42b855a4b0.patch
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
From c764ca71a639f5585b5f466bea25dc42b855a4b0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
|
||||||
|
Date: Mon, 25 Apr 2022 14:42:51 -0300
|
||||||
|
Subject: [PATCH] Bug: Wrong code generation in bitwise operations
|
||||||
|
|
||||||
|
---
|
||||||
|
lcode.c | 16 ++++++++++------
|
||||||
|
ltests.h | 7 +++++++
|
||||||
|
testes/constructs.lua | 25 +++++++++++++++++++++++++
|
||||||
|
3 files changed, 42 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lcode.c b/lcode.c
|
||||||
|
index 06425a1db..cb724a090 100644
|
||||||
|
--- a/src/lcode.c
|
||||||
|
+++ b/src/lcode.c
|
||||||
|
@@ -1391,7 +1391,10 @@ static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2,
|
||||||
|
*/
|
||||||
|
static void codebinexpval (FuncState *fs, OpCode op,
|
||||||
|
expdesc *e1, expdesc *e2, int line) {
|
||||||
|
- int v2 = luaK_exp2anyreg(fs, e2); /* both operands are in registers */
|
||||||
|
+ int v2 = luaK_exp2anyreg(fs, e2); /* make sure 'e2' is in a register */
|
||||||
|
+ /* 'e1' must be already in a register or it is a constant */
|
||||||
|
+ lua_assert((VNIL <= e1->k && e1->k <= VKSTR) ||
|
||||||
|
+ e1->k == VNONRELOC || e1->k == VRELOC);
|
||||||
|
lua_assert(OP_ADD <= op && op <= OP_SHR);
|
||||||
|
finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN,
|
||||||
|
cast(TMS, (op - OP_ADD) + TM_ADD));
|
||||||
|
@@ -1478,7 +1481,7 @@ static void codecommutative (FuncState *fs, BinOpr op,
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
-** Code bitwise operations; they are all associative, so the function
|
||||||
|
+** Code bitwise operations; they are all commutative, so the function
|
||||||
|
** tries to put an integer constant as the 2nd operand (a K operand).
|
||||||
|
*/
|
||||||
|
static void codebitwise (FuncState *fs, BinOpr opr,
|
||||||
|
@@ -1486,11 +1489,11 @@ static void codebitwise (FuncState *fs, BinOpr opr,
|
||||||
|
int flip = 0;
|
||||||
|
int v2;
|
||||||
|
OpCode op;
|
||||||
|
- if (e1->k == VKINT && luaK_exp2RK(fs, e1)) {
|
||||||
|
+ if (e1->k == VKINT && luaK_exp2K(fs, e1)) {
|
||||||
|
swapexps(e1, e2); /* 'e2' will be the constant operand */
|
||||||
|
flip = 1;
|
||||||
|
}
|
||||||
|
- else if (!(e2->k == VKINT && luaK_exp2RK(fs, e2))) { /* no constants? */
|
||||||
|
+ else if (!(e2->k == VKINT && luaK_exp2K(fs, e2))) { /* no constants? */
|
||||||
|
op = cast(OpCode, opr + OP_ADD);
|
||||||
|
codebinexpval(fs, op, e1, e2, line); /* all-register opcodes */
|
||||||
|
return;
|
||||||
|
@@ -1551,7 +1554,7 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
|
||||||
|
op = OP_EQI;
|
||||||
|
r2 = im; /* immediate operand */
|
||||||
|
}
|
||||||
|
- else if (luaK_exp2RK(fs, e2)) { /* 1st expression is constant? */
|
||||||
|
+ else if (luaK_exp2RK(fs, e2)) { /* 2nd expression is constant? */
|
||||||
|
op = OP_EQK;
|
||||||
|
r2 = e2->u.info; /* constant index */
|
||||||
|
}
|
||||||
|
@@ -1611,7 +1614,8 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
|
||||||
|
case OPR_SHL: case OPR_SHR: {
|
||||||
|
if (!tonumeral(v, NULL))
|
||||||
|
luaK_exp2anyreg(fs, v);
|
||||||
|
- /* else keep numeral, which may be folded with 2nd operand */
|
||||||
|
+ /* else keep numeral, which may be folded or used as an immediate
|
||||||
|
+ operand */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case OPR_EQ: case OPR_NE: {
|
||||||
|
diff --git a/ltests.h b/ltests.h
|
||||||
|
index cb3a0b480..ec520498b 100644
|
||||||
|
--- a/lua-5.4.4-tests/ltests/ltests.h
|
||||||
|
+++ b/lua-5.4.4-tests/ltests/ltests.h
|
||||||
|
@@ -125,6 +125,13 @@ LUA_API void *debug_realloc (void *ud, void *block,
|
||||||
|
#define LUAI_USER_ALIGNMENT_T union { char b[sizeof(void*) * 8]; }
|
||||||
|
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+** This one is not compatible with tests for opcode optimizations,
|
||||||
|
+** as it blocks some optimizations
|
||||||
|
+#define MAXINDEXRK 0
|
||||||
|
+*/
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/* make stack-overflow tests run faster */
|
||||||
|
#undef LUAI_MAXSTACK
|
||||||
|
#define LUAI_MAXSTACK 50000
|
||||||
|
diff --git a/testes/constructs.lua b/testes/constructs.lua
|
||||||
|
index a74a8c041..0d9ec92d7 100644
|
||||||
|
--- a/lua-5.4.4-tests/constructs.lua
|
||||||
|
+++ b/lua-5.4.4-tests/constructs.lua
|
||||||
|
@@ -103,6 +103,31 @@ do -- test old bug (first name could not be an `upvalue')
|
||||||
|
local a; function f(x) x={a=1}; x={x=1}; x={G=1} end
|
||||||
|
end
|
||||||
|
|
||||||
|
+
|
||||||
|
+do -- bug since 5.4.0
|
||||||
|
+ -- create code with a table using more than 256 constants
|
||||||
|
+ local code = {"local x = {"}
|
||||||
|
+ for i = 1, 257 do
|
||||||
|
+ code[#code + 1] = i .. ".1,"
|
||||||
|
+ end
|
||||||
|
+ code[#code + 1] = "};"
|
||||||
|
+ code = table.concat(code)
|
||||||
|
+
|
||||||
|
+ -- add "ret" to the end of that code and checks that
|
||||||
|
+ -- it produces the expected value "val"
|
||||||
|
+ local function check (ret, val)
|
||||||
|
+ local code = code .. ret
|
||||||
|
+ code = load(code)
|
||||||
|
+ assert(code() == val)
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
+ check("return (1 ~ (2 or 3))", 1 ~ 2)
|
||||||
|
+ check("return (1 | (2 or 3))", 1 | 2)
|
||||||
|
+ check("return (1 + (2 or 3))", 1 + 2)
|
||||||
|
+ check("return (1 << (2 or 3))", 1 << 2)
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+
|
||||||
|
function f (i)
|
||||||
|
if type(i) ~= 'number' then return i,'jojo'; end;
|
||||||
|
if i > 0 then return i, f(i-1); end;
|
26
lua-5.3.5-CVE-2020-24370.patch
Normal file
26
lua-5.3.5-CVE-2020-24370.patch
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
diff -up lua-5.3.5/src/ldebug.c.CVE-2020-24370 lua-5.3.5/src/ldebug.c
|
||||||
|
--- lua-5.3.5/src/ldebug.c.CVE-2020-24370 2020-08-19 13:37:17.075859557 -0400
|
||||||
|
+++ lua-5.3.5/src/ldebug.c 2020-08-19 13:38:53.117779244 -0400
|
||||||
|
@@ -133,10 +133,11 @@ static const char *upvalname (Proto *p,
|
||||||
|
|
||||||
|
static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
|
||||||
|
int nparams = clLvalue(ci->func)->p->numparams;
|
||||||
|
- if (n >= cast_int(ci->u.l.base - ci->func) - nparams)
|
||||||
|
+ int nvararg = cast_int(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
|
||||||
|
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));
|
54
lua-5.3.5-luac-shared-link-fix.patch
Normal file
54
lua-5.3.5-luac-shared-link-fix.patch
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
diff -up lua-5.3.5/src/lopcodes.c.luac-shared lua-5.3.5/src/lopcodes.c
|
||||||
|
--- lua-5.3.5/src/lopcodes.c.luac-shared 2019-10-23 15:36:44.487204487 -0400
|
||||||
|
+++ lua-5.3.5/src/lopcodes.c 2019-10-23 15:37:44.029960930 -0400
|
||||||
|
@@ -17,7 +17,7 @@
|
||||||
|
|
||||||
|
/* ORDER OP */
|
||||||
|
|
||||||
|
-LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
|
||||||
|
+LUA_API const char *const luaP_opnames[NUM_OPCODES+1] = {
|
||||||
|
"MOVE",
|
||||||
|
"LOADK",
|
||||||
|
"LOADKX",
|
||||||
|
@@ -71,7 +71,7 @@ LUAI_DDEF const char *const luaP_opnames
|
||||||
|
|
||||||
|
#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
|
||||||
|
|
||||||
|
-LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
|
||||||
|
+LUA_API const lu_byte luaP_opmodes[NUM_OPCODES] = {
|
||||||
|
/* T A B C mode opcode */
|
||||||
|
opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
|
||||||
|
,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
|
||||||
|
diff -up lua-5.3.5/src/lopcodes.h.luac-shared lua-5.3.5/src/lopcodes.h
|
||||||
|
--- lua-5.3.5/src/lopcodes.h.luac-shared 2019-10-23 15:37:52.982773948 -0400
|
||||||
|
+++ lua-5.3.5/src/lopcodes.h 2019-10-23 15:38:17.861254367 -0400
|
||||||
|
@@ -278,7 +278,7 @@ enum OpArgMask {
|
||||||
|
OpArgK /* argument is a constant or register/constant */
|
||||||
|
};
|
||||||
|
|
||||||
|
-LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES];
|
||||||
|
+LUA_API const lu_byte luaP_opmodes[NUM_OPCODES];
|
||||||
|
|
||||||
|
#define getOpMode(m) (cast(enum OpMode, luaP_opmodes[m] & 3))
|
||||||
|
#define getBMode(m) (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
|
||||||
|
@@ -287,7 +287,7 @@ LUAI_DDEC const lu_byte luaP_opmodes[NUM
|
||||||
|
#define testTMode(m) (luaP_opmodes[m] & (1 << 7))
|
||||||
|
|
||||||
|
|
||||||
|
-LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
|
||||||
|
+LUA_API const char *const luaP_opnames[NUM_OPCODES+1]; /* opcode names */
|
||||||
|
|
||||||
|
|
||||||
|
/* number of list items to accumulate before a SETLIST instruction */
|
||||||
|
diff -up lua-5.3.5/src/lundump.h.luac-shared lua-5.3.5/src/lundump.h
|
||||||
|
--- lua-5.3.5/src/lundump.h.luac-shared 2019-10-23 15:38:46.707651903 -0400
|
||||||
|
+++ lua-5.3.5/src/lundump.h 2019-10-23 15:39:07.044227180 -0400
|
||||||
|
@@ -26,7 +26,7 @@
|
||||||
|
LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name);
|
||||||
|
|
||||||
|
/* dump one chunk; from ldump.c */
|
||||||
|
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
|
||||||
|
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w,
|
||||||
|
void* data, int strip);
|
||||||
|
|
||||||
|
#endif
|
192
lua-5.4.0-beta-autotoolize.patch
Normal file
192
lua-5.4.0-beta-autotoolize.patch
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
diff -up lua-5.4.0-beta/configure.ac.autoxxx lua-5.4.0-beta/configure.ac
|
||||||
|
--- lua-5.4.0-beta/configure.ac.autoxxx 2019-10-23 15:03:13.296916443 -0400
|
||||||
|
+++ lua-5.4.0-beta/configure.ac 2019-10-23 15:03:13.296916443 -0400
|
||||||
|
@@ -0,0 +1,69 @@
|
||||||
|
+AC_PREREQ(2.59)
|
||||||
|
+AC_INIT([lua], [5.4.0], [https://bugzilla.redhat.com/], [lua-at], [http://www.lua.org])
|
||||||
|
+AC_SUBST([MAJOR_VERSION], [5.4])
|
||||||
|
+
|
||||||
|
+AC_CONFIG_HEADERS([config.h])
|
||||||
|
+AC_CONFIG_SRCDIR([src/lapi.c])
|
||||||
|
+
|
||||||
|
+AM_INIT_AUTOMAKE([1.9 foreign])
|
||||||
|
+
|
||||||
|
+AC_PROG_CC
|
||||||
|
+AC_PROG_LIBTOOL
|
||||||
|
+
|
||||||
|
+AC_ARG_WITH(
|
||||||
|
+ [readline],
|
||||||
|
+ [AC_HELP_STRING([--with-readline], [Use readline for interpreter input [default=yes]])],
|
||||||
|
+ [use_readline=$withval],
|
||||||
|
+ [use_readline=yes]
|
||||||
|
+)
|
||||||
|
+
|
||||||
|
+LUA_LIBS="-lm"
|
||||||
|
+
|
||||||
|
+# Check for readline
|
||||||
|
+READLINE_DEFS="#undef LUA_USE_READLINE"
|
||||||
|
+if test "x$use_readline" == "xyes"; then
|
||||||
|
+ AC_CHECK_LIB([readline], [readline], [:], [use_readline=no], [-lncurses])
|
||||||
|
+ AC_CHECK_HEADERS([readline/readline.h readline/history.h], [], [use_readline=no])
|
||||||
|
+ if test "x$use_readline" == "xno"; then
|
||||||
|
+ AC_MSG_WARN([readline headers could not be found, disabling readline support])
|
||||||
|
+ else
|
||||||
|
+ READLINE_DEFS="#define LUA_USE_READLINE"
|
||||||
|
+ READLINE_LIBS="-lreadline -lncurses"
|
||||||
|
+ fi
|
||||||
|
+fi
|
||||||
|
+AC_SUBST(READLINE_DEFS)
|
||||||
|
+AC_SUBST(READLINE_LIBS)
|
||||||
|
+
|
||||||
|
+case "$host" in
|
||||||
|
+ *-mingw*) use_os=win32 ;;
|
||||||
|
+ *-darwin*) use_os=macosx ;;
|
||||||
|
+ *) use_os=posix ;;
|
||||||
|
+esac
|
||||||
|
+
|
||||||
|
+POSIX_DEFS="#undef LUA_USE_POSIX"
|
||||||
|
+LUA_DL_DEFS="#undef LUA_USE_DLOPEN"
|
||||||
|
+LUA_BUILD_AS_DLL_DEFS="#undef LUA_BUILD_AS_DLL"
|
||||||
|
+
|
||||||
|
+if test "x$use_os" == "xwin32"; then
|
||||||
|
+ LUA_BUILD_AS_DLL_DEFS="#define LUA_BUILD_AS_DLL"
|
||||||
|
+elif test "x$use_os" == "xmacosx"; then
|
||||||
|
+ POSIX_DEFS="#define LUA_USE_POSIX"
|
||||||
|
+ LUA_DL_DEFS="#define LUA_DL_DYLD"
|
||||||
|
+elif test "x$use_os" == "xposix"; then
|
||||||
|
+ POSIX_DEFS="#define LUA_USE_POSIX"
|
||||||
|
+ LUA_DL_DEFS="#define LUA_DL_DLOPEN"
|
||||||
|
+ LUA_LIBS="$LUA_LIBS -ldl"
|
||||||
|
+fi
|
||||||
|
+AC_SUBST(POSIX_DEFS)
|
||||||
|
+AC_SUBST(LUA_DL_DEFS)
|
||||||
|
+AC_SUBST(LUA_BUILD_AS_DLL_DEFS)
|
||||||
|
+
|
||||||
|
+AC_SUBST(LUA_LIBS)
|
||||||
|
+
|
||||||
|
+AC_CONFIG_FILES([Makefile
|
||||||
|
+ src/Makefile
|
||||||
|
+ src/lua.pc
|
||||||
|
+ src/luaconf.h.template
|
||||||
|
+ doc/Makefile
|
||||||
|
+])
|
||||||
|
+AC_OUTPUT
|
||||||
|
diff -up lua-5.4.0-beta/doc/Makefile.am.autoxxx lua-5.4.0-beta/doc/Makefile.am
|
||||||
|
--- lua-5.4.0-beta/doc/Makefile.am.autoxxx 2019-10-23 15:03:13.296916443 -0400
|
||||||
|
+++ lua-5.4.0-beta/doc/Makefile.am 2019-10-23 15:03:13.296916443 -0400
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+man1_MANS = lua.1 luac.1
|
||||||
|
+
|
||||||
|
+EXTRA_DIST = \
|
||||||
|
+ contents.html logo.gif lua.1 luac.1 lua.css manual.css manual.html osi-certified-72x60.png readme.html
|
||||||
|
diff -up lua-5.4.0-beta/Makefile.am.autoxxx lua-5.4.0-beta/Makefile.am
|
||||||
|
--- lua-5.4.0-beta/Makefile.am.autoxxx 2019-10-23 15:03:13.296916443 -0400
|
||||||
|
+++ lua-5.4.0-beta/Makefile.am 2019-10-23 15:03:13.296916443 -0400
|
||||||
|
@@ -0,0 +1,3 @@
|
||||||
|
+SUBDIRS = src doc
|
||||||
|
+
|
||||||
|
+EXTRA_DIST = README
|
||||||
|
diff -up lua-5.4.0-beta/src/.gitignore.autoxxx lua-5.4.0-beta/src/.gitignore
|
||||||
|
--- lua-5.4.0-beta/src/.gitignore.autoxxx 2019-10-23 15:03:13.297916423 -0400
|
||||||
|
+++ lua-5.4.0-beta/src/.gitignore 2019-10-23 15:03:13.296916443 -0400
|
||||||
|
@@ -0,0 +1,5 @@
|
||||||
|
+lua
|
||||||
|
+lua.pc
|
||||||
|
+luac
|
||||||
|
+luaconf.h
|
||||||
|
+luaconf.h.template
|
||||||
|
diff -up lua-5.4.0-beta/src/luaconf.h.template.in.autoxxx lua-5.4.0-beta/src/luaconf.h.template.in
|
||||||
|
--- lua-5.4.0-beta/src/luaconf.h.template.in.autoxxx 2019-09-30 19:52:16.000000000 -0400
|
||||||
|
+++ lua-5.4.0-beta/src/luaconf.h.template.in 2019-10-23 15:05:45.139817627 -0400
|
||||||
|
@@ -11,6 +11,11 @@
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
+@POSIX_DEFS@
|
||||||
|
+@LUA_DL_DEFS@
|
||||||
|
+@LUA_BUILD_AS_DLL_DEFS@
|
||||||
|
+@READLINE_DEFS@
|
||||||
|
+
|
||||||
|
|
||||||
|
/*
|
||||||
|
** ===================================================================
|
||||||
|
@@ -227,9 +232,9 @@
|
||||||
|
|
||||||
|
#else /* }{ */
|
||||||
|
|
||||||
|
-#define LUA_ROOT "/usr/local/"
|
||||||
|
-#define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/"
|
||||||
|
-#define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/"
|
||||||
|
+#define LUA_ROOT "@prefix@/"
|
||||||
|
+#define LUA_LDIR "@pkgdatadir@/lua/" LUA_VDIR "/"
|
||||||
|
+#define LUA_CDIR "@libdir@/lua/" LUA_VDIR "/"
|
||||||
|
|
||||||
|
#if !defined(LUA_PATH_DEFAULT)
|
||||||
|
#define LUA_PATH_DEFAULT \
|
||||||
|
diff -up lua-5.4.0-beta/src/lua.pc.in.autoxxx lua-5.4.0-beta/src/lua.pc.in
|
||||||
|
--- lua-5.4.0-beta/src/lua.pc.in.autoxxx 2019-10-23 15:03:13.297916423 -0400
|
||||||
|
+++ lua-5.4.0-beta/src/lua.pc.in 2019-10-23 15:03:13.297916423 -0400
|
||||||
|
@@ -0,0 +1,13 @@
|
||||||
|
+V= @MAJOR_VERSION@
|
||||||
|
+R= @VERSION@
|
||||||
|
+prefix= @prefix@
|
||||||
|
+exec_prefix=${prefix}
|
||||||
|
+libdir= @libdir@
|
||||||
|
+includedir=${prefix}/include
|
||||||
|
+
|
||||||
|
+Name: Lua
|
||||||
|
+Description: An Extensible Extension Language
|
||||||
|
+Version: ${R}
|
||||||
|
+Requires:
|
||||||
|
+Libs: -llua @LUA_LIBS@
|
||||||
|
+Cflags: -I${includedir}
|
||||||
|
diff -up lua-5.4.0-beta/src/Makefile.am.autoxxx lua-5.4.0-beta/src/Makefile.am
|
||||||
|
--- lua-5.4.0-beta/src/Makefile.am.autoxxx 2019-10-23 15:03:13.297916423 -0400
|
||||||
|
+++ lua-5.4.0-beta/src/Makefile.am 2019-10-23 15:03:13.297916423 -0400
|
||||||
|
@@ -0,0 +1,46 @@
|
||||||
|
+AM_CFLAGS = -Wall
|
||||||
|
+
|
||||||
|
+include_HEADERS = lua.h lualib.h lauxlib.h lua.hpp
|
||||||
|
+
|
||||||
|
+nodist_include_HEADERS = luaconf.h
|
||||||
|
+
|
||||||
|
+lib_LTLIBRARIES = liblua.la
|
||||||
|
+liblua_la_LDFLAGS = -release @MAJOR_VERSION@
|
||||||
|
+liblua_la_SOURCES = \
|
||||||
|
+ lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c ldblib.c \
|
||||||
|
+ ldebug.c ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c \
|
||||||
|
+ loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c lstrlib.c \
|
||||||
|
+ ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c \
|
||||||
|
+ lapi.h lcode.h lctype.h ldebug.h ldo.h lfunc.h lgc.h llex.h llimits.h \
|
||||||
|
+ lmem.h lobject.h lopcodes.h lparser.h lstate.h lstring.h ltable.h ltm.h \
|
||||||
|
+ lundump.h lvm.h lzio.h
|
||||||
|
+
|
||||||
|
+pkgconfigdir = $(libdir)/pkgconfig
|
||||||
|
+pkgconfig_DATA = lua.pc
|
||||||
|
+
|
||||||
|
+bin_PROGRAMS = lua luac
|
||||||
|
+
|
||||||
|
+lua_SOURCES = lua.c
|
||||||
|
+lua_LDADD = liblua.la @LUA_LIBS@ @READLINE_LIBS@
|
||||||
|
+lua_DEPENDENCIES = liblua.la
|
||||||
|
+
|
||||||
|
+luac_SOURCES = luac.c
|
||||||
|
+# Statically link liblua against luac since luac uses symbols not exported in liblua
|
||||||
|
+luac_LDADD = .libs/liblua.a @LUA_LIBS@
|
||||||
|
+luac_DEPENDENCIES = liblua.la
|
||||||
|
+
|
||||||
|
+EXTRA_DIST = luaconf.h.template
|
||||||
|
+BUILT_SOURCES = luaconf.h
|
||||||
|
+CLEANFILES = luaconf.h luaconf.h.template
|
||||||
|
+
|
||||||
|
+readline_defs = @READLINE_DEFS@
|
||||||
|
+
|
||||||
|
+edit = sed \
|
||||||
|
+ -e 's,%prefix%,$(prefix),g' \
|
||||||
|
+ -e 's,%lua_datadir%,$(datadir),g' \
|
||||||
|
+ -e 's,%lua_libdir%,$(libdir),g'
|
||||||
|
+
|
||||||
|
+luaconf.h : luaconf.h.template
|
||||||
|
+ rm -f $@ $@.tmp
|
||||||
|
+ $(edit) $< >$@.tmp
|
||||||
|
+ mv $@.tmp $@
|
11
lua-5.4.3-CVE-2021-44647.patch
Normal file
11
lua-5.4.3-CVE-2021-44647.patch
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
diff -up lua-5.4.3/src/lstate.c.CVE-2021-44647 lua-5.4.3/src/lstate.c
|
||||||
|
--- lua-5.4.3/src/lstate.c.CVE-2021-44647 2022-01-24 11:15:00.851544455 -0500
|
||||||
|
+++ lua-5.4.3/src/lstate.c 2022-01-24 11:15:27.187694727 -0500
|
||||||
|
@@ -271,6 +271,7 @@ static void close_state (lua_State *L) {
|
||||||
|
if (!completestate(g)) /* closing a partially built state? */
|
||||||
|
luaC_freeallobjects(L); /* jucst collect its objects */
|
||||||
|
else { /* closing a fully built state */
|
||||||
|
+ L->ci = &L->base_ci; /* unwind CallInfo list */
|
||||||
|
luaD_closeprotected(L, 1, LUA_OK); /* close all upvalues */
|
||||||
|
luaC_freeallobjects(L); /* collect all objects */
|
||||||
|
luai_userstateclose(L);
|
261
lua-5.4.3-bug10.patch
Normal file
261
lua-5.4.3-bug10.patch
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
diff -up lua-5.4.3/lua-5.4.3-tests/api.lua.bug10 lua-5.4.3/lua-5.4.3-tests/api.lua
|
||||||
|
--- lua-5.4.3/lua-5.4.3-tests/api.lua.bug10 2022-01-24 17:07:28.084973092 -0500
|
||||||
|
+++ lua-5.4.3/lua-5.4.3-tests/api.lua 2022-01-24 17:08:50.306551450 -0500
|
||||||
|
@@ -804,15 +804,14 @@ F = function (x)
|
||||||
|
d = nil
|
||||||
|
assert(debug.getmetatable(x).__gc == F)
|
||||||
|
assert(load("table.insert({}, {})"))() -- create more garbage
|
||||||
|
- collectgarbage() -- force a GC during GC
|
||||||
|
- assert(debug.getmetatable(x).__gc == F) -- previous GC did not mess this?
|
||||||
|
+ assert(not collectgarbage()) -- GC during GC (no op)
|
||||||
|
local dummy = {} -- create more garbage during GC
|
||||||
|
if A ~= nil then
|
||||||
|
assert(type(A) == "userdata")
|
||||||
|
assert(T.udataval(A) == B)
|
||||||
|
debug.getmetatable(A) -- just access it
|
||||||
|
end
|
||||||
|
- A = x -- ressucita userdata
|
||||||
|
+ A = x -- ressurect userdata
|
||||||
|
B = udval
|
||||||
|
return 1,2,3
|
||||||
|
end
|
||||||
|
diff -up lua-5.4.3/lua-5.4.3-tests/gc.lua.bug10 lua-5.4.3/lua-5.4.3-tests/gc.lua
|
||||||
|
--- lua-5.4.3/lua-5.4.3-tests/gc.lua.bug10 2022-01-24 17:08:57.241600231 -0500
|
||||||
|
+++ lua-5.4.3/lua-5.4.3-tests/gc.lua 2022-01-24 17:10:20.100183086 -0500
|
||||||
|
@@ -676,11 +676,13 @@ end
|
||||||
|
-- just to make sure
|
||||||
|
assert(collectgarbage'isrunning')
|
||||||
|
|
||||||
|
-do -- check that the collector is reentrant in incremental mode
|
||||||
|
+do -- check that the collector is not reentrant in incremental mode
|
||||||
|
+ local res = true
|
||||||
|
setmetatable({}, {__gc = function ()
|
||||||
|
- collectgarbage()
|
||||||
|
+ res = collectgarbage()
|
||||||
|
end})
|
||||||
|
collectgarbage()
|
||||||
|
+ assert(not res)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
diff -up lua-5.4.3/src/lapi.c.bug10 lua-5.4.3/src/lapi.c
|
||||||
|
--- lua-5.4.3/src/lapi.c.bug10 2022-01-24 16:56:54.409515673 -0500
|
||||||
|
+++ lua-5.4.3/src/lapi.c 2022-01-24 16:59:36.136653287 -0500
|
||||||
|
@@ -1126,18 +1126,19 @@ LUA_API int lua_status (lua_State *L) {
|
||||||
|
LUA_API int lua_gc (lua_State *L, int what, ...) {
|
||||||
|
va_list argp;
|
||||||
|
int res = 0;
|
||||||
|
- global_State *g;
|
||||||
|
+ global_State *g = G(L);
|
||||||
|
+ if (g->gcstp & GCSTPGC) /* internal stop? */
|
||||||
|
+ return -1; /* all options are invalid when stopped */
|
||||||
|
lua_lock(L);
|
||||||
|
- g = G(L);
|
||||||
|
va_start(argp, what);
|
||||||
|
switch (what) {
|
||||||
|
case LUA_GCSTOP: {
|
||||||
|
- g->gcrunning = 0;
|
||||||
|
+ g->gcstp = GCSTPUSR; /* stopeed by the user */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LUA_GCRESTART: {
|
||||||
|
luaE_setdebt(g, 0);
|
||||||
|
- g->gcrunning = 1;
|
||||||
|
+ g->gcstp = 0; /* (GCSTPGC must be already zero here) */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LUA_GCCOLLECT: {
|
||||||
|
@@ -1156,8 +1157,8 @@ LUA_API int lua_gc (lua_State *L, int wh
|
||||||
|
case LUA_GCSTEP: {
|
||||||
|
int data = va_arg(argp, int);
|
||||||
|
l_mem debt = 1; /* =1 to signal that it did an actual step */
|
||||||
|
- lu_byte oldrunning = g->gcrunning;
|
||||||
|
- g->gcrunning = 1; /* allow GC to run */
|
||||||
|
+ lu_byte oldstp = g->gcstp;
|
||||||
|
+ g->gcstp = 0; /* allow GC to run (GCSTPGC must be zero here) */
|
||||||
|
if (data == 0) {
|
||||||
|
luaE_setdebt(g, 0); /* do a basic step */
|
||||||
|
luaC_step(L);
|
||||||
|
@@ -1167,7 +1168,7 @@ LUA_API int lua_gc (lua_State *L, int wh
|
||||||
|
luaE_setdebt(g, debt);
|
||||||
|
luaC_checkGC(L);
|
||||||
|
}
|
||||||
|
- g->gcrunning = oldrunning; /* restore previous state */
|
||||||
|
+ g->gcstp = oldstp; /* restore previous state */
|
||||||
|
if (debt > 0 && g->gcstate == GCSpause) /* end of cycle? */
|
||||||
|
res = 1; /* signal it */
|
||||||
|
break;
|
||||||
|
@@ -1185,7 +1186,7 @@ LUA_API int lua_gc (lua_State *L, int wh
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LUA_GCISRUNNING: {
|
||||||
|
- res = g->gcrunning;
|
||||||
|
+ res = gcrunning(g);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LUA_GCGEN: {
|
||||||
|
diff -up lua-5.4.3/src/lbaselib.c.bug10 lua-5.4.3/src/lbaselib.c
|
||||||
|
--- lua-5.4.3/src/lbaselib.c.bug10 2022-01-24 16:59:43.337703940 -0500
|
||||||
|
+++ lua-5.4.3/src/lbaselib.c 2022-01-24 17:02:19.898805225 -0500
|
||||||
|
@@ -182,12 +182,20 @@ static int luaB_rawset (lua_State *L) {
|
||||||
|
|
||||||
|
|
||||||
|
static int pushmode (lua_State *L, int oldmode) {
|
||||||
|
- lua_pushstring(L, (oldmode == LUA_GCINC) ? "incremental"
|
||||||
|
- : "generational");
|
||||||
|
+ if (oldmode == -1)
|
||||||
|
+ luaL_pushfail(L); /* invalid call to 'lua_gc' */
|
||||||
|
+ else
|
||||||
|
+ lua_pushstring(L, (oldmode == LUA_GCINC) ? "incremental"
|
||||||
|
+ : "generational");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+** check whether call to 'lua_gc' was valid (not inside a finalizer)
|
||||||
|
+*/
|
||||||
|
+#define checkvalres(res) { if (res == -1) break; }
|
||||||
|
+
|
||||||
|
static int luaB_collectgarbage (lua_State *L) {
|
||||||
|
static const char *const opts[] = {"stop", "restart", "collect",
|
||||||
|
"count", "step", "setpause", "setstepmul",
|
||||||
|
@@ -200,12 +208,14 @@ static int luaB_collectgarbage (lua_Stat
|
||||||
|
case LUA_GCCOUNT: {
|
||||||
|
int k = lua_gc(L, o);
|
||||||
|
int b = lua_gc(L, LUA_GCCOUNTB);
|
||||||
|
+ checkvalres(k);
|
||||||
|
lua_pushnumber(L, (lua_Number)k + ((lua_Number)b/1024));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case LUA_GCSTEP: {
|
||||||
|
int step = (int)luaL_optinteger(L, 2, 0);
|
||||||
|
int res = lua_gc(L, o, step);
|
||||||
|
+ checkvalres(res);
|
||||||
|
lua_pushboolean(L, res);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@@ -213,11 +223,13 @@ static int luaB_collectgarbage (lua_Stat
|
||||||
|
case LUA_GCSETSTEPMUL: {
|
||||||
|
int p = (int)luaL_optinteger(L, 2, 0);
|
||||||
|
int previous = lua_gc(L, o, p);
|
||||||
|
+ checkvalres(previous);
|
||||||
|
lua_pushinteger(L, previous);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case LUA_GCISRUNNING: {
|
||||||
|
int res = lua_gc(L, o);
|
||||||
|
+ checkvalres(res);
|
||||||
|
lua_pushboolean(L, res);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@@ -234,10 +246,13 @@ static int luaB_collectgarbage (lua_Stat
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
int res = lua_gc(L, o);
|
||||||
|
+ checkvalres(res);
|
||||||
|
lua_pushinteger(L, res);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ luaL_pushfail(L); /* invalid call (inside a finalizer) */
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
diff -up lua-5.4.3/src/lgc.c.bug10 lua-5.4.3/src/lgc.c
|
||||||
|
--- lua-5.4.3/src/lgc.c.bug10 2022-01-24 17:02:30.231877910 -0500
|
||||||
|
+++ lua-5.4.3/src/lgc.c 2022-01-24 17:04:02.486526852 -0500
|
||||||
|
@@ -906,16 +906,16 @@ static void GCTM (lua_State *L) {
|
||||||
|
if (!notm(tm)) { /* is there a finalizer? */
|
||||||
|
int status;
|
||||||
|
lu_byte oldah = L->allowhook;
|
||||||
|
- int running = g->gcrunning;
|
||||||
|
+ int oldgcstp = g->gcstp;
|
||||||
|
+ g->gcstp = GCSTPGC; /* avoid GC steps */
|
||||||
|
L->allowhook = 0; /* stop debug hooks during GC metamethod */
|
||||||
|
- g->gcrunning = 0; /* avoid GC steps */
|
||||||
|
setobj2s(L, L->top++, tm); /* push finalizer... */
|
||||||
|
setobj2s(L, L->top++, &v); /* ... and its argument */
|
||||||
|
L->ci->callstatus |= CIST_FIN; /* will run a finalizer */
|
||||||
|
status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
|
||||||
|
L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */
|
||||||
|
L->allowhook = oldah; /* restore hooks */
|
||||||
|
- g->gcrunning = running; /* restore state */
|
||||||
|
+ g->gcstp = oldgcstp; /* restore state */
|
||||||
|
if (l_unlikely(status != LUA_OK)) { /* error while running __gc? */
|
||||||
|
luaE_warnerror(L, "__gc metamethod");
|
||||||
|
L->top--; /* pops error object */
|
||||||
|
@@ -1502,9 +1502,11 @@ static void deletelist (lua_State *L, GC
|
||||||
|
*/
|
||||||
|
void luaC_freeallobjects (lua_State *L) {
|
||||||
|
global_State *g = G(L);
|
||||||
|
+ g->gcstp = GCSTPGC;
|
||||||
|
luaC_changemode(L, KGC_INC);
|
||||||
|
separatetobefnz(g, 1); /* separate all objects with finalizers */
|
||||||
|
lua_assert(g->finobj == NULL);
|
||||||
|
+ g->gcstp = 0;
|
||||||
|
callallpendingfinalizers(L);
|
||||||
|
deletelist(L, g->allgc, obj2gco(g->mainthread));
|
||||||
|
deletelist(L, g->finobj, NULL);
|
||||||
|
@@ -1678,7 +1680,7 @@ static void incstep (lua_State *L, globa
|
||||||
|
void luaC_step (lua_State *L) {
|
||||||
|
global_State *g = G(L);
|
||||||
|
lua_assert(!g->gcemergency);
|
||||||
|
- if (g->gcrunning) { /* running? */
|
||||||
|
+ if (gcrunning(g)) { /* running? */
|
||||||
|
if(isdecGCmodegen(g))
|
||||||
|
genstep(L, g);
|
||||||
|
else
|
||||||
|
diff -up lua-5.4.3/src/lgc.h.bug10 lua-5.4.3/src/lgc.h
|
||||||
|
--- lua-5.4.3/src/lgc.h.bug10 2022-01-24 17:04:08.890571899 -0500
|
||||||
|
+++ lua-5.4.3/src/lgc.h 2022-01-24 17:04:41.260799595 -0500
|
||||||
|
@@ -148,6 +148,15 @@
|
||||||
|
*/
|
||||||
|
#define isdecGCmodegen(g) (g->gckind == KGC_GEN || g->lastatomic != 0)
|
||||||
|
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+** Control when GC is running:
|
||||||
|
+*/
|
||||||
|
+#define GCSTPUSR 1 /* bit true when GC stopped by user */
|
||||||
|
+#define GCSTPGC 2 /* bit true when GC stopped by itself */
|
||||||
|
+#define gcrunning(g) ((g)->gcstp == 0)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
** Does one step of collection when debt becomes positive. 'pre'/'pos'
|
||||||
|
** allows some adjustments to be done only when needed. macro
|
||||||
|
diff -up lua-5.4.3/src/lstate.c.bug10 lua-5.4.3/src/lstate.c
|
||||||
|
--- lua-5.4.3/src/lstate.c.bug10 2022-01-24 17:04:51.775873561 -0500
|
||||||
|
+++ lua-5.4.3/src/lstate.c 2022-01-24 17:05:26.544118136 -0500
|
||||||
|
@@ -236,7 +236,7 @@ static void f_luaopen (lua_State *L, voi
|
||||||
|
luaS_init(L);
|
||||||
|
luaT_init(L);
|
||||||
|
luaX_init(L);
|
||||||
|
- g->gcrunning = 1; /* allow gc */
|
||||||
|
+ g->gcstp = 0; /* allow gc */
|
||||||
|
setnilvalue(&g->nilvalue); /* now state is complete */
|
||||||
|
luai_userstateopen(L);
|
||||||
|
}
|
||||||
|
@@ -373,7 +373,7 @@ LUA_API lua_State *lua_newstate (lua_All
|
||||||
|
g->ud_warn = NULL;
|
||||||
|
g->mainthread = L;
|
||||||
|
g->seed = luai_makeseed(L);
|
||||||
|
- g->gcrunning = 0; /* no GC while building state */
|
||||||
|
+ g->gcstp = GCSTPGC; /* no GC while building state */
|
||||||
|
g->strt.size = g->strt.nuse = 0;
|
||||||
|
g->strt.hash = NULL;
|
||||||
|
setnilvalue(&g->l_registry);
|
||||||
|
diff -up lua-5.4.3/src/lstate.h.bug10 lua-5.4.3/src/lstate.h
|
||||||
|
--- lua-5.4.3/src/lstate.h.bug10 2022-01-24 17:05:30.179143707 -0500
|
||||||
|
+++ lua-5.4.3/src/lstate.h 2022-01-24 17:07:05.577814767 -0500
|
||||||
|
@@ -263,7 +263,7 @@ typedef struct global_State {
|
||||||
|
lu_byte gcstopem; /* stops emergency collections */
|
||||||
|
lu_byte genminormul; /* control for minor generational collections */
|
||||||
|
lu_byte genmajormul; /* control for major generational collections */
|
||||||
|
- lu_byte gcrunning; /* true if GC is running */
|
||||||
|
+ lu_byte gcstp; /* control whether GC is running */
|
||||||
|
lu_byte gcemergency; /* true if this is an emergency collection */
|
||||||
|
lu_byte gcpause; /* size of pause between successive GCs */
|
||||||
|
lu_byte gcstepmul; /* GC "speed" */
|
32
lua-5.4.3-bug3.patch
Normal file
32
lua-5.4.3-bug3.patch
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
diff -up lua-5.4.3/src/lvm.c.bug3 lua-5.4.3/src/lvm.c
|
||||||
|
--- lua-5.4.3/src/lvm.c.bug3 2021-04-28 13:27:54.025590350 -0400
|
||||||
|
+++ lua-5.4.3/src/lvm.c 2021-04-28 13:28:55.233614835 -0400
|
||||||
|
@@ -847,10 +847,19 @@ void luaV_finishOp (lua_State *L) {
|
||||||
|
luaV_concat(L, total); /* concat them (may yield again) */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
- case OP_CLOSE: case OP_RETURN: { /* yielded closing variables */
|
||||||
|
+ case OP_CLOSE: { /* yielded closing variables */
|
||||||
|
ci->u.l.savedpc--; /* repeat instruction to close other vars. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
+ case OP_RETURN: { /* yielded closing variables */
|
||||||
|
+ StkId ra = base + GETARG_A(inst);
|
||||||
|
+ /* correct top to signal correct number of returns (in case the
|
||||||
|
+ return is "in top" */
|
||||||
|
+ L->top = ra + ci->u2.nres;
|
||||||
|
+ /* repeat instruction to close other vars. and complete the return */
|
||||||
|
+ ci->u.l.savedpc--;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
default: {
|
||||||
|
/* only these other opcodes can yield */
|
||||||
|
lua_assert(op == OP_TFORCALL || op == OP_CALL ||
|
||||||
|
@@ -1670,6 +1679,7 @@ void luaV_execute (lua_State *L, CallInf
|
||||||
|
n = cast_int(L->top - ra); /* get what is available */
|
||||||
|
savepc(ci);
|
||||||
|
if (TESTARG_k(i)) { /* may there be open upvalues? */
|
||||||
|
+ ci->u2.nres = n; /* save number of returns */
|
||||||
|
if (L->top < ci->top)
|
||||||
|
L->top = ci->top;
|
||||||
|
luaF_close(L, base, CLOSEKTOP, 1);
|
23
lua-5.4.3-bug4.patch
Normal file
23
lua-5.4.3-bug4.patch
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
diff -up lua-5.4.3/lua-5.4.3-tests/locals.lua.bug4 lua-5.4.3/lua-5.4.3-tests/locals.lua
|
||||||
|
--- lua-5.4.3/lua-5.4.3-tests/locals.lua.bug4 2022-01-24 11:21:11.757660851 -0500
|
||||||
|
+++ lua-5.4.3/lua-5.4.3-tests/locals.lua 2022-01-24 11:21:34.088788271 -0500
|
||||||
|
@@ -187,6 +187,8 @@ do -- constants
|
||||||
|
checkro("y", "local x, y <const>, z = 10, 20, 30; x = 11; y = 12")
|
||||||
|
checkro("x", "local x <const>, y, z <const> = 10, 20, 30; x = 11")
|
||||||
|
checkro("z", "local x <const>, y, z <const> = 10, 20, 30; y = 10; z = 11")
|
||||||
|
+ checkro("foo", "local foo <const> = 10; function foo() end")
|
||||||
|
+ checkro("foo", "local foo <const> = {}; function foo() end")
|
||||||
|
|
||||||
|
checkro("z", [[
|
||||||
|
local a, z <const>, b = 10;
|
||||||
|
diff -up lua-5.4.3/src/lparser.c.bug4 lua-5.4.3/src/lparser.c
|
||||||
|
--- lua-5.4.3/src/lparser.c.bug4 2022-01-24 11:20:27.808410077 -0500
|
||||||
|
+++ lua-5.4.3/src/lparser.c 2022-01-24 11:20:49.592534377 -0500
|
||||||
|
@@ -1776,6 +1776,7 @@ static void funcstat (LexState *ls, int
|
||||||
|
luaX_next(ls); /* skip FUNCTION */
|
||||||
|
ismethod = funcname(ls, &v);
|
||||||
|
body(ls, &b, ismethod, line);
|
||||||
|
+ check_readonly(ls, &v);
|
||||||
|
luaK_storevar(ls->fs, &v, &b);
|
||||||
|
luaK_fixline(ls->fs, line); /* definition "happens" in the first line */
|
||||||
|
}
|
11
lua-5.4.3-bug5.patch
Normal file
11
lua-5.4.3-bug5.patch
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
diff -up lua-5.4.3/src/lauxlib.c.bug5 lua-5.4.3/src/lauxlib.c
|
||||||
|
--- lua-5.4.3/src/lauxlib.c.bug5 2022-01-24 11:23:19.763391239 -0500
|
||||||
|
+++ lua-5.4.3/src/lauxlib.c 2022-01-24 11:23:52.554578345 -0500
|
||||||
|
@@ -881,6 +881,7 @@ LUALIB_API lua_Integer luaL_len (lua_Sta
|
||||||
|
|
||||||
|
|
||||||
|
LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
|
||||||
|
+ idx = lua_absindex(L,idx);
|
||||||
|
if (luaL_callmeta(L, idx, "__tostring")) { /* metafield? */
|
||||||
|
if (!lua_isstring(L, -1))
|
||||||
|
luaL_error(L, "'__tostring' must return a string");
|
12
lua-5.4.3-bug6.patch
Normal file
12
lua-5.4.3-bug6.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
diff -up lua-5.4.3/src/lvm.c.bug6 lua-5.4.3/src/lvm.c
|
||||||
|
--- lua-5.4.3/src/lvm.c.bug6 2022-01-24 11:25:20.620080850 -0500
|
||||||
|
+++ lua-5.4.3/src/lvm.c 2022-01-24 11:25:46.443228197 -0500
|
||||||
|
@@ -766,7 +766,7 @@ lua_Number luaV_modf (lua_State *L, lua_
|
||||||
|
/*
|
||||||
|
** Shift left operation. (Shift right just negates 'y'.)
|
||||||
|
*/
|
||||||
|
-#define luaV_shiftr(x,y) luaV_shiftl(x,-(y))
|
||||||
|
+#define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y))
|
||||||
|
|
||||||
|
lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) {
|
||||||
|
if (y < 0) { /* shift right? */
|
50
lua-5.4.3-bug7.patch
Normal file
50
lua-5.4.3-bug7.patch
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
diff -up lua-5.4.3/lua-5.4.3-tests/cstack.lua.bug7 lua-5.4.3/lua-5.4.3-tests/cstack.lua
|
||||||
|
--- lua-5.4.3/lua-5.4.3-tests/cstack.lua.bug7 2022-01-24 11:29:00.412334975 -0500
|
||||||
|
+++ lua-5.4.3/lua-5.4.3-tests/cstack.lua 2022-01-24 11:32:08.101405924 -0500
|
||||||
|
@@ -103,6 +103,20 @@ do
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
+do -- bug in 5.4.2
|
||||||
|
+ print("nesting coroutines running after recoverable errors")
|
||||||
|
+ local count = 0
|
||||||
|
+ local function foo()
|
||||||
|
+ count = count + 1
|
||||||
|
+ pcall(1) -- create an error
|
||||||
|
+ -- running now inside 'precover' ("protected recover")
|
||||||
|
+ coroutine.wrap(foo)() -- call another coroutine
|
||||||
|
+ end
|
||||||
|
+ checkerror("C stack overflow", foo)
|
||||||
|
+ print("final count: ", count)
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+
|
||||||
|
if T then
|
||||||
|
print("testing stack recovery")
|
||||||
|
local N = 0 -- trace number of calls
|
||||||
|
diff -up lua-5.4.3/src/ldo.c.bug7 lua-5.4.3/src/ldo.c
|
||||||
|
--- lua-5.4.3/src/ldo.c.bug7 2022-01-24 11:27:41.226883145 -0500
|
||||||
|
+++ lua-5.4.3/src/ldo.c 2022-01-24 11:28:45.374249175 -0500
|
||||||
|
@@ -728,11 +728,10 @@ static void resume (lua_State *L, void *
|
||||||
|
StkId firstArg = L->top - n; /* first argument */
|
||||||
|
CallInfo *ci = L->ci;
|
||||||
|
if (L->status == LUA_OK) /* starting a coroutine? */
|
||||||
|
- ccall(L, firstArg - 1, LUA_MULTRET, 1); /* just call its body */
|
||||||
|
+ ccall(L, firstArg - 1, LUA_MULTRET, 0); /* just call its body */
|
||||||
|
else { /* resuming from previous yield */
|
||||||
|
lua_assert(L->status == LUA_YIELD);
|
||||||
|
L->status = LUA_OK; /* mark that it is running (again) */
|
||||||
|
- luaE_incCstack(L); /* control the C stack */
|
||||||
|
if (isLua(ci)) { /* yielded inside a hook? */
|
||||||
|
L->top = firstArg; /* discard arguments */
|
||||||
|
luaV_execute(L, ci); /* just continue running Lua code */
|
||||||
|
@@ -783,6 +782,9 @@ LUA_API int lua_resume (lua_State *L, lu
|
||||||
|
else if (L->status != LUA_YIELD) /* ended with errors? */
|
||||||
|
return resume_error(L, "cannot resume dead coroutine", nargs);
|
||||||
|
L->nCcalls = (from) ? getCcalls(from) : 0;
|
||||||
|
+ if (getCcalls(L) >= LUAI_MAXCCALLS)
|
||||||
|
+ return resume_error(L, "C stack overflow", nargs);
|
||||||
|
+ L->nCcalls++;
|
||||||
|
luai_userstateresume(L, nargs);
|
||||||
|
api_checknelems(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
|
||||||
|
status = luaD_rawrunprotected(L, resume, &nargs);
|
143
lua-5.4.3-bug8.patch
Normal file
143
lua-5.4.3-bug8.patch
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
diff -up lua-5.4.3/lua-5.4.3-tests/coroutine.lua.bug8 lua-5.4.3/lua-5.4.3-tests/coroutine.lua
|
||||||
|
--- lua-5.4.3/lua-5.4.3-tests/coroutine.lua.bug8 2022-01-24 13:52:57.345650003 -0500
|
||||||
|
+++ lua-5.4.3/lua-5.4.3-tests/coroutine.lua 2022-01-24 13:55:46.679628140 -0500
|
||||||
|
@@ -137,11 +137,16 @@ do
|
||||||
|
local st, msg = coroutine.close(co)
|
||||||
|
assert(st and msg == nil)
|
||||||
|
|
||||||
|
+
|
||||||
|
-- cannot close the running coroutine
|
||||||
|
local st, msg = pcall(coroutine.close, coroutine.running())
|
||||||
|
assert(not st and string.find(msg, "running"))
|
||||||
|
|
||||||
|
local main = coroutine.running()
|
||||||
|
+ -- also ok to close it again
|
||||||
|
+ st, msg = coroutine.close(co)
|
||||||
|
+ assert(st and msg == nil)
|
||||||
|
+
|
||||||
|
|
||||||
|
-- cannot close a "normal" coroutine
|
||||||
|
;(coroutine.wrap(function ()
|
||||||
|
@@ -149,6 +154,22 @@ do
|
||||||
|
assert(not st and string.find(msg, "normal"))
|
||||||
|
end))()
|
||||||
|
|
||||||
|
+ -- cannot close a coroutine while closing it
|
||||||
|
+ do
|
||||||
|
+ local co
|
||||||
|
+ co = coroutine.create(
|
||||||
|
+ function()
|
||||||
|
+ local x <close> = func2close(function()
|
||||||
|
+ coroutine.close(co) -- try to close it again
|
||||||
|
+ end)
|
||||||
|
+ coroutine.yield(20)
|
||||||
|
+ end)
|
||||||
|
+ local st, msg = coroutine.resume(co)
|
||||||
|
+ assert(st and msg == 20)
|
||||||
|
+ st, msg = coroutine.close(co)
|
||||||
|
+ assert(not st and string.find(msg, "running coroutine"))
|
||||||
|
+ end
|
||||||
|
+
|
||||||
|
-- to-be-closed variables in coroutines
|
||||||
|
local X
|
||||||
|
|
||||||
|
@@ -158,6 +179,9 @@ do
|
||||||
|
assert(not st and msg == 100)
|
||||||
|
st, msg = coroutine.close(co)
|
||||||
|
assert(not st and msg == 100)
|
||||||
|
+ -- after closing, no more errors
|
||||||
|
+ st, msg = coroutine.close(co)
|
||||||
|
+ assert(st and msg == nil)
|
||||||
|
|
||||||
|
co = coroutine.create(function ()
|
||||||
|
local x <close> = func2close(function (self, err)
|
||||||
|
@@ -189,6 +213,9 @@ do
|
||||||
|
local st, msg = coroutine.close(co)
|
||||||
|
assert(st == false and coroutine.status(co) == "dead" and msg == 200)
|
||||||
|
assert(x == 200)
|
||||||
|
+ -- after closing, no more errors
|
||||||
|
+ st, msg = coroutine.close(co)
|
||||||
|
+ assert(st and msg == nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
do
|
||||||
|
@@ -419,7 +446,7 @@ do
|
||||||
|
|
||||||
|
local X = false
|
||||||
|
A = coroutine.wrap(function()
|
||||||
|
- local _ <close> = setmetatable({}, {__close = function () X = true end})
|
||||||
|
+ local _ <close> = func2close(function () X = true end)
|
||||||
|
return pcall(A, 1)
|
||||||
|
end)
|
||||||
|
st, res = A()
|
||||||
|
@@ -427,6 +454,22 @@ do
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
+-- bug in 5.4.1
|
||||||
|
+do
|
||||||
|
+ -- coroutine ran close metamethods with invalid status during a
|
||||||
|
+ -- reset.
|
||||||
|
+ local co
|
||||||
|
+ co = coroutine.wrap(function()
|
||||||
|
+ local x <close> = func2close(function() return pcall(co) end)
|
||||||
|
+ error(111)
|
||||||
|
+ end)
|
||||||
|
+ local st, errobj = pcall(co)
|
||||||
|
+ assert(not st and errobj == 111)
|
||||||
|
+ st, errobj = pcall(co)
|
||||||
|
+ assert(not st and string.find(errobj, "dead coroutine"))
|
||||||
|
+end
|
||||||
|
+
|
||||||
|
+
|
||||||
|
-- attempt to resume 'normal' coroutine
|
||||||
|
local co1, co2
|
||||||
|
co1 = coroutine.create(function () return co2() end)
|
||||||
|
diff -up lua-5.4.3/src/lcorolib.c.bug8 lua-5.4.3/src/lcorolib.c
|
||||||
|
--- lua-5.4.3/src/lcorolib.c.bug8 2022-01-24 13:51:10.238031307 -0500
|
||||||
|
+++ lua-5.4.3/src/lcorolib.c 2022-01-24 13:51:58.951312692 -0500
|
||||||
|
@@ -78,7 +78,7 @@ static int luaB_auxwrap (lua_State *L) {
|
||||||
|
if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */
|
||||||
|
stat = lua_resetthread(co); /* close its tbc variables */
|
||||||
|
lua_assert(stat != LUA_OK);
|
||||||
|
- lua_xmove(co, L, 1); /* copy error message */
|
||||||
|
+ lua_xmove(co, L, 1); /* move error message to the caller */
|
||||||
|
}
|
||||||
|
if (stat != LUA_ERRMEM && /* not a memory error and ... */
|
||||||
|
lua_type(L, -1) == LUA_TSTRING) { /* ... error object is a string? */
|
||||||
|
@@ -179,7 +179,7 @@ static int luaB_close (lua_State *L) {
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lua_pushboolean(L, 0);
|
||||||
|
- lua_xmove(co, L, 1); /* copy error message */
|
||||||
|
+ lua_xmove(co, L, 1); /* move error message */
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff -up lua-5.4.3/src/lstate.c.bug8 lua-5.4.3/src/lstate.c
|
||||||
|
--- lua-5.4.3/src/lstate.c.bug8 2022-01-24 13:52:07.581362543 -0500
|
||||||
|
+++ lua-5.4.3/src/lstate.c 2022-01-24 13:52:40.932555194 -0500
|
||||||
|
@@ -166,7 +166,7 @@ void luaE_checkcstack (lua_State *L) {
|
||||||
|
if (getCcalls(L) == LUAI_MAXCCALLS)
|
||||||
|
luaG_runerror(L, "C stack overflow");
|
||||||
|
else if (getCcalls(L) >= (LUAI_MAXCCALLS / 10 * 11))
|
||||||
|
- luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
|
||||||
|
+ luaD_throw(L, LUA_ERRERR); /* error while handling stack error */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -331,13 +331,13 @@ int luaE_resetthread (lua_State *L, int
|
||||||
|
ci->callstatus = CIST_C;
|
||||||
|
if (status == LUA_YIELD)
|
||||||
|
status = LUA_OK;
|
||||||
|
+ L->status = LUA_OK; /* so it can run __close metamethods */
|
||||||
|
status = luaD_closeprotected(L, 1, status);
|
||||||
|
if (status != LUA_OK) /* errors? */
|
||||||
|
luaD_seterrorobj(L, status, L->stack + 1);
|
||||||
|
else
|
||||||
|
L->top = L->stack + 1;
|
||||||
|
ci->top = L->top + LUA_MINSTACK;
|
||||||
|
- L->status = cast_byte(status);
|
||||||
|
luaD_reallocstack(L, cast_int(ci->top - L->stack), 0);
|
||||||
|
return status;
|
||||||
|
}
|
137
lua.spec
137
lua.spec
@ -1,49 +1,55 @@
|
|||||||
%global major_version 5.3
|
%global major_version 5.4
|
||||||
# Normally, this is the same as version, but... not always.
|
# Normally, this is the same as version, but... not always.
|
||||||
# No tests yet for 5.3.5
|
%global test_version 5.4.4
|
||||||
%global test_version 5.3.4
|
|
||||||
# If you are incrementing major_version, enable bootstrapping and adjust accordingly.
|
# If you are incrementing major_version, enable bootstrapping and adjust accordingly.
|
||||||
# Version should be the latest prior build. If you don't do this, RPM will break and
|
# Version should be the latest prior build. If you don't do this, RPM will break and
|
||||||
# everything will grind to a halt.
|
# everything will grind to a halt.
|
||||||
%global bootstrap 0
|
%global bootstrap 1
|
||||||
%global bootstrap_major_version 5.2
|
%global bootstrap_major_version 5.3
|
||||||
%global bootstrap_version %{bootstrap_major_version}.3
|
%global bootstrap_version %{bootstrap_major_version}.6
|
||||||
|
|
||||||
# Place rpm-macros into proper location.
|
# Place rpm-macros into proper location.
|
||||||
%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
|
%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
|
||||||
|
|
||||||
|
|
||||||
Name: lua
|
Name: lua
|
||||||
Version: %{major_version}.5
|
Version: %{major_version}.4
|
||||||
Release: 7%{?dist}
|
Release: 4%{?dist}
|
||||||
Summary: Powerful light-weight programming language
|
Summary: Powerful light-weight programming language
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: http://www.lua.org/
|
URL: https://www.lua.org/
|
||||||
Source0: http://www.lua.org/ftp/lua-%{version}.tar.gz
|
Source0: https://www.lua.org/ftp/lua-%{version}.tar.gz
|
||||||
# copied from doc/readme.html on 2014-07-18
|
# copied from doc/readme.html on 2014-07-18
|
||||||
Source1: mit.txt
|
Source1: mit.txt
|
||||||
%if 0%{?bootstrap}
|
%if 0%{?bootstrap}
|
||||||
Source2: http://www.lua.org/ftp/lua-%{bootstrap_version}.tar.gz
|
Source2: https://www.lua.org/ftp/lua-%{bootstrap_version}.tar.gz
|
||||||
%endif
|
%endif
|
||||||
Source3: http://www.lua.org/tests/lua-%{test_version}-tests.tar.gz
|
Source3: https://www.lua.org/tests/lua-%{test_version}-tests.tar.gz
|
||||||
# multilib
|
# multilib
|
||||||
Source4: luaconf.h
|
Source4: luaconf.h
|
||||||
# rpm-macro
|
Patch0: %{name}-5.4.0-beta-autotoolize.patch
|
||||||
Source1000: macros.lua
|
|
||||||
Patch0: %{name}-5.3.0-autotoolize.patch
|
|
||||||
Patch1: %{name}-5.3.0-idsize.patch
|
Patch1: %{name}-5.3.0-idsize.patch
|
||||||
#Patch2: %%{name}-5.3.0-luac-shared-link-fix.patch
|
#Patch2: %%{name}-5.3.0-luac-shared-link-fix.patch
|
||||||
Patch3: %{name}-5.2.2-configure-linux.patch
|
Patch3: %{name}-5.2.2-configure-linux.patch
|
||||||
Patch4: %{name}-5.3.0-configure-compat-module.patch
|
Patch4: %{name}-5.3.0-configure-compat-module.patch
|
||||||
%if 0%{?bootstrap}
|
%if 0%{?bootstrap}
|
||||||
Patch5: %{name}-5.2.3-autotoolize.patch
|
Patch5: %{name}-5.3.0-autotoolize.patch
|
||||||
Patch6: %{name}-5.2.2-idsize.patch
|
Patch6: %{name}-5.3.5-luac-shared-link-fix.patch
|
||||||
Patch7: %{name}-5.2.2-luac-shared-link-fix.patch
|
|
||||||
Patch8: %{name}-5.2.2-configure-compat-module.patch
|
|
||||||
%endif
|
%endif
|
||||||
Patch9: CVE-2019-6706-use-after-free-lua_upvaluejoin.patch
|
# https://www.lua.org/bugs.html
|
||||||
|
# 5.4.4 Bug 1
|
||||||
|
Patch7: https://github.com/lua/lua/commit/25b143dd34fb587d1e35290c4b25bc08954800e2.patch
|
||||||
|
# 5.4.4 Bug 2
|
||||||
|
Patch8: https://github.com/lua/lua/commit/1f3c6f4534c6411313361697d98d1145a1f030fa.patch
|
||||||
|
# 5.4.4 Bug 3
|
||||||
|
Patch9: https://github.com/lua/lua/commit/c764ca71a639f5585b5f466bea25dc42b855a4b0.patch
|
||||||
|
# 5.4.4 Bug 4
|
||||||
|
Patch10: https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf.patch
|
||||||
|
# 5.4.4 Bug 5
|
||||||
|
Patch11: https://github.com/lua/lua/commit/196bb94d66e727e0aec053a0276c3ad701500762.patch
|
||||||
|
|
||||||
BuildRequires: automake autoconf libtool readline-devel ncurses-devel
|
BuildRequires: automake autoconf libtool readline-devel ncurses-devel
|
||||||
|
BuildRequires: make
|
||||||
Requires: lua-libs = %{version}-%{release}
|
Requires: lua-libs = %{version}-%{release}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -59,6 +65,9 @@ configuration, scripting, and rapid prototyping.
|
|||||||
%package devel
|
%package devel
|
||||||
Summary: Development files for %{name}
|
Summary: Development files for %{name}
|
||||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||||
|
# The RPM related dependencies bring nothing to a non-RPM Lua developer
|
||||||
|
# But we want them when packages BuildRequire lua-devel
|
||||||
|
Requires: (lua-rpm-macros if rpm-build)
|
||||||
Requires: pkgconfig
|
Requires: pkgconfig
|
||||||
|
|
||||||
%description devel
|
%description devel
|
||||||
@ -81,7 +90,7 @@ This package contains the static version of liblua for %{name}.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%if 0%{?bootstrap}
|
%if 0%{?bootstrap}
|
||||||
%setup -q -a 2 -a 3
|
%setup -q -a 2 -a 3 -n %{name}-%{version}
|
||||||
%else
|
%else
|
||||||
%setup -q -a 3
|
%setup -q -a 3
|
||||||
%endif
|
%endif
|
||||||
@ -92,7 +101,11 @@ mv src/luaconf.h src/luaconf.h.template.in
|
|||||||
#%% patch2 -p1 -z .luac-shared
|
#%% patch2 -p1 -z .luac-shared
|
||||||
%patch3 -p1 -z .configure-linux
|
%patch3 -p1 -z .configure-linux
|
||||||
%patch4 -p1 -z .configure-compat-all
|
%patch4 -p1 -z .configure-compat-all
|
||||||
%patch9 -p1 -b .CVE-2019-6706
|
%patch7 -p1 -b .5.4.4-bug1
|
||||||
|
%patch8 -p1 -b .5.4.4-bug2
|
||||||
|
%patch9 -p1 -b .5.4.4-bug3
|
||||||
|
%patch10 -p1 -b .5.4.4-bug4
|
||||||
|
%patch11 -p1 -b .5.4.4-bug5
|
||||||
# Put proper version in configure.ac, patch0 hardcodes 5.3.0
|
# Put proper version in configure.ac, patch0 hardcodes 5.3.0
|
||||||
sed -i 's|5.3.0|%{version}|g' configure.ac
|
sed -i 's|5.3.0|%{version}|g' configure.ac
|
||||||
autoreconf -ifv
|
autoreconf -ifv
|
||||||
@ -101,10 +114,10 @@ autoreconf -ifv
|
|||||||
cd lua-%{bootstrap_version}/
|
cd lua-%{bootstrap_version}/
|
||||||
mv src/luaconf.h src/luaconf.h.template.in
|
mv src/luaconf.h src/luaconf.h.template.in
|
||||||
%patch5 -p1 -b .autoxxx
|
%patch5 -p1 -b .autoxxx
|
||||||
%patch6 -p1 -b .idsize
|
%patch1 -p1 -b .idsize
|
||||||
%patch7 -p1 -b .luac-shared
|
|
||||||
%patch3 -p1 -z .configure-linux
|
%patch3 -p1 -z .configure-linux
|
||||||
%patch8 -p1 -z .configure-compat-all
|
%patch4 -p1 -z .configure-compat-all
|
||||||
|
%patch6 -p1 -b .luac-shared-link-fix
|
||||||
autoreconf -i
|
autoreconf -i
|
||||||
cd ..
|
cd ..
|
||||||
%endif
|
%endif
|
||||||
@ -119,7 +132,7 @@ sed -i 's|@pkgdatadir@|%{_datadir}|g' src/luaconf.h.template
|
|||||||
|
|
||||||
# hack so that only /usr/bin/lua gets linked with readline as it is the
|
# hack so that only /usr/bin/lua gets linked with readline as it is the
|
||||||
# only one which needs this and otherwise we get License troubles
|
# only one which needs this and otherwise we get License troubles
|
||||||
make %{?_smp_mflags} LIBS="-lm -ldl"
|
%make_build LIBS="-lm -ldl"
|
||||||
# only /usr/bin/lua links with readline now #luac_LDADD="liblua.la -lm -ldl"
|
# only /usr/bin/lua links with readline now #luac_LDADD="liblua.la -lm -ldl"
|
||||||
|
|
||||||
%if 0%{?bootstrap}
|
%if 0%{?bootstrap}
|
||||||
@ -132,7 +145,7 @@ sed -i 's|@pkgdatadir@|%{_datadir}|g' src/luaconf.h.template
|
|||||||
|
|
||||||
# hack so that only /usr/bin/lua gets linked with readline as it is the
|
# hack so that only /usr/bin/lua gets linked with readline as it is the
|
||||||
# only one which needs this and otherwise we get License troubles
|
# only one which needs this and otherwise we get License troubles
|
||||||
make %{?_smp_mflags} LIBS="-lm -ldl" luac_LDADD="liblua.la -lm -ldl"
|
%make_build LIBS="-lm -ldl" luac_LDADD="liblua.la -lm -ldl"
|
||||||
popd
|
popd
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
@ -156,7 +169,7 @@ sed -i.orig -e '
|
|||||||
LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{_libdir} $RPM_BUILD_ROOT/%{_bindir}/lua -e"_U=true" all.lua
|
LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{_libdir} $RPM_BUILD_ROOT/%{_bindir}/lua -e"_U=true" all.lua
|
||||||
|
|
||||||
%install
|
%install
|
||||||
make install DESTDIR=$RPM_BUILD_ROOT
|
%make_install
|
||||||
rm $RPM_BUILD_ROOT%{_libdir}/*.la
|
rm $RPM_BUILD_ROOT%{_libdir}/*.la
|
||||||
mkdir -p $RPM_BUILD_ROOT%{_libdir}/lua/%{major_version}
|
mkdir -p $RPM_BUILD_ROOT%{_libdir}/lua/%{major_version}
|
||||||
mkdir -p $RPM_BUILD_ROOT%{_datadir}/lua/%{major_version}
|
mkdir -p $RPM_BUILD_ROOT%{_datadir}/lua/%{major_version}
|
||||||
@ -177,9 +190,6 @@ rm -rf $RPM_BUILD_ROOT/installdir
|
|||||||
popd
|
popd
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
# Install rpm-macro
|
|
||||||
install -Dpm 0644 %{SOURCE1000} $RPM_BUILD_ROOT/%{macrosdir}/macros.lua
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%{!?_licensedir:%global license %%doc}
|
%{!?_licensedir:%global license %%doc}
|
||||||
%license mit.txt
|
%license mit.txt
|
||||||
@ -207,13 +217,74 @@ install -Dpm 0644 %{SOURCE1000} $RPM_BUILD_ROOT/%{macrosdir}/macros.lua
|
|||||||
%{_includedir}/l*.hpp
|
%{_includedir}/l*.hpp
|
||||||
%{_libdir}/liblua.so
|
%{_libdir}/liblua.so
|
||||||
%{_libdir}/pkgconfig/*.pc
|
%{_libdir}/pkgconfig/*.pc
|
||||||
%{macrosdir}/macros.lua
|
|
||||||
|
|
||||||
%files static
|
%files static
|
||||||
%{_libdir}/*.a
|
%{_libdir}/*.a
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.4.4-4
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Jul 19 2022 Tom Callaway <spot@fedoraproject.org> - 5.4.4-3
|
||||||
|
- upstream bug fixes (3,4,5) including fix for CVE-2022-33099
|
||||||
|
|
||||||
|
* Tue Apr 5 2022 Tom Callaway <spot@fedoraproject.org> - 5.4.4-2
|
||||||
|
- upstream bug fixes
|
||||||
|
|
||||||
|
* Tue Feb 1 2022 Tom Callaway <spot@fedoraproject.org> - 5.4.4-1
|
||||||
|
- update to 5.4.4, update bootstrap code to 5.3.6
|
||||||
|
- 5.4.4 contains the fix for 5.4.3 bug7, which is also CVE-2021-43519
|
||||||
|
This fix was also in 5.4.3-4, so you do not need to update solely for that.
|
||||||
|
|
||||||
|
* Mon Jan 24 2022 Tom Callaway <spot@fedoraproject.org> - 5.4.3-4
|
||||||
|
- apply upstream fix for CVE-2021-44647
|
||||||
|
- apply upstream fixes for known lua bugs 4-10 (11 assumes other changes beyond 5.4.3)
|
||||||
|
|
||||||
|
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.4.3-3
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.4.3-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
||||||
|
|
||||||
|
* Wed Mar 31 2021 Tom Callaway <spot@fedoraproject.org> - 5.4.3-1
|
||||||
|
- update to 5.4.3
|
||||||
|
- apply fix for bug3
|
||||||
|
|
||||||
|
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.4.2-2
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||||
|
|
||||||
|
* Thu Dec 3 2020 Tom Callaway <spot@fedoraproject.org> - 5.4.2-1
|
||||||
|
- update to 5.4.2
|
||||||
|
|
||||||
|
* Mon Oct 12 2020 Tom Callaway <spot@fedoraproject.org> - 5.4.1-1
|
||||||
|
- update to 5.4.1
|
||||||
|
|
||||||
|
* Wed Sep 2 2020 Tom Callaway <spot@fedoraproject.org> - 5.4.0-8
|
||||||
|
- apply upstream fix for CVE-2020-24342
|
||||||
|
|
||||||
|
* Mon Aug 31 2020 Michel Alexandre Salim <salimma@fedoraproject.org> - 5.4.0-7
|
||||||
|
- Refactor macros into lua-rpm-macros
|
||||||
|
|
||||||
|
* Wed Aug 19 2020 Tom Callaway <spot@fedoraproject.org> - 5.4.0-6
|
||||||
|
- apply upstream fix for CVE-2020-24370, CVE-2020-24371
|
||||||
|
|
||||||
|
* Wed Aug 19 2020 Tom Callaway <spot@fedoraproject.org> - 5.4.0-5
|
||||||
|
- apply upstream fix for CVE-2020-24369
|
||||||
|
|
||||||
|
* Fri Jul 31 2020 Tom Callaway <spot@fedoraproject.org> - 5.4.0-4
|
||||||
|
- apply upstream fix for CVE-2020-15889
|
||||||
|
- apply upstream fix for CVE-2020-15945
|
||||||
|
- apply upstream fixes for "known bugs"
|
||||||
|
|
||||||
|
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 5.4.0-3
|
||||||
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
|
||||||
|
|
||||||
|
* Tue Jun 30 2020 Miro Hrončok <mhroncok@redhat.com> - 5.4.0-2
|
||||||
|
- Add lua(abi) requirements generator (requires RPM 4.16+)
|
||||||
|
|
||||||
|
* Mon Jun 29 2020 Tom Callaway <spot@fedoraproject.org> - 5.4.0-1
|
||||||
|
- update to 5.4.0
|
||||||
|
|
||||||
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.5-7
|
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.5-7
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
|
||||||
|
|
||||||
|
13
macros.lua
13
macros.lua
@ -1,13 +0,0 @@
|
|||||||
%lua_version %{lua: print(string.sub(_VERSION, 5))}
|
|
||||||
|
|
||||||
%lua_libdir %{_libdir}/lua/%{lua_version}
|
|
||||||
%lua_pkgdir %{_datadir}/lua/%{lua_version}
|
|
||||||
|
|
||||||
%lua_requires \
|
|
||||||
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 \
|
|
||||||
Requires: lua(abi) = %{lua_version} \
|
|
||||||
%else \
|
|
||||||
Requires: lua >= %{lua_version} \
|
|
||||||
Requires: lua < %{lua: os.setlocale('C'); print(string.sub(_VERSION, 5) + 0.1)} \
|
|
||||||
%endif \
|
|
||||||
%{nil}
|
|
6
sources
6
sources
@ -1,3 +1,3 @@
|
|||||||
SHA512 (lua-5.2.3.tar.gz) = 264bb7c8db2f190ef0ca38584ec81999ab588f54e03119c5214c40bb8925b0eb407fac483a03e40cc8a220f6748ddff7d3a7392da3803418276b0d263b866449
|
SHA512 (lua-5.4.4.tar.gz) = af0c35d5ba00fecbb2dd617bd7b825edf7418a16a73076e04f2a0df58cdbf098dc3ff4402e974afd789eb5d86d2e12ec6df9c84b99b23656ea694a85f83bcd21
|
||||||
SHA512 (lua-5.3.4-tests.tar.gz) = 79575d100a2efabc8243f55b55d912443e09ef7e8b0219cb93541d85c2ba802fb9538015e1228703f09ca57bdb28a640a8f1fa0735716ba1e4bca2179c712dfb
|
SHA512 (lua-5.4.4-tests.tar.gz) = 08b3d764b3f362a2cddf5a23e71b16eea96a234a970fa0048bab358ebbd77f99d9bd132af12254383c5bb5426516e1ce2107e529e88d3963869255f5a41198ef
|
||||||
SHA512 (lua-5.3.5.tar.gz) = 4f9516acc4659dfd0a9e911bfa00c0788f0ad9348e5724fe8fb17aac59e9c0060a64378f82be86f8534e49c6c013e7488ad17321bafcc787831d3d67406bd0f4
|
SHA512 (lua-5.3.6.tar.gz) = ccc380d5e114d54504de0bfb0321ca25ec325d6ff1bfee44b11870b660762d1a9bf120490c027a0088128b58bb6b5271bbc648400cab84d2dc22b512c4841681
|
||||||
|
Loading…
Reference in New Issue
Block a user