Compare commits

...

104 Commits
f8 ... rawhide

Author SHA1 Message Date
Fedora Release Engineering f08586b17f Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-21 19:59:17 +00:00
Tom spot Callaway b831eb6988 upstream bug fixes (3,4,5) including fix for CVE-2022-33099 2022-07-19 10:47:29 -04:00
Tom spot Callaway 7dabd5ee69 Merge branch 'rawhide' of ssh://pkgs.fedoraproject.org/rpms/lua into rawhide 2022-04-05 15:36:23 -04:00
Tom spot Callaway 8dad25e9a4 upstream bug fixes 2022-04-05 14:27:45 -04:00
Miro Hrončok fd3a8e4b75 Use HTTPS URLs 2022-02-03 17:21:58 +01:00
Tom spot Callaway 0adfa0746e 5.4.4, 5.3.6 2022-02-01 13:56:29 -05:00
Tom spot Callaway 8050c843bd apply upstream fix for CVE-2021-44647, apply upstream fixes for known lua bugs 4-10 (11 assumes other changes beyond 5.4.3) 2022-01-24 17:23:29 -05:00
Fedora Release Engineering fd778929eb - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-01-20 18:11:24 +00:00
Fedora Release Engineering e86927ce21 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-07-22 13:15:36 +00:00
Timm Bäder 786a69eca4 Use make macros
https://docs.fedoraproject.org/en-US/packaging-guidelines/#_parallel_make
2021-05-04 18:15:29 +02:00
Tom spot Callaway 0c7ff179d8 merge 2021-04-28 13:40:22 -04:00
Tom spot Callaway 96be13d24e 5.4.3 2021-04-28 13:35:31 -04:00
Fedora Release Engineering 058dca212c - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-01-26 18:47:22 +00:00
Tom Stellard dc3e772ee9 Add BuildRequires: make
https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot
2021-01-05 03:30:16 +00:00
Tom spot Callaway 54c3992cf5 Merge branch 'master' into f33 2020-12-03 10:22:55 -05:00
Tom spot Callaway da74cc970e 5.4.2 2020-12-03 10:22:31 -05:00
Tom Callaway 4b02202aa0 Merge branch 'master' into f33 2020-10-12 14:33:30 -04:00
Tom Callaway 3e03dd9b69 5.4.1 2020-10-12 13:53:38 -04:00
Michel Alexandre Salim 23a9922b41 Merge branch 'master' into f33
Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
2020-09-02 19:14:56 -07:00
Tom Callaway a178517865 CVE-2020-24342 2020-09-02 15:09:42 -04:00
Tom Callaway fae2e38de7 silence changelog noise 2020-09-02 15:06:31 -04:00
Tom Callaway 4b399374b6 CVE-2020-24342 2020-09-02 15:05:28 -04:00
Michel Alexandre Salim a043d07614 Refactor macros into lua-rpm-macros
Signed-off-by: Michel Alexandre Salim <salimma@fedoraproject.org>
2020-08-31 17:27:50 -07:00
Tom Callaway c4db958ec0 CVE-2020-24370, CVE-2020-24371 2020-08-19 13:45:22 -04:00
Tom Callaway 0439a5e58a comment 2020-08-19 13:01:03 -04:00
Tom Callaway b9107ac261 apply upstream fix for CVE-2020-24369 2020-08-19 12:59:54 -04:00
Tom Callaway f8bc6d8ddc apply upstream fixes for CVE-2020-15889, CVE-2020-15945, and other known bugs 2020-07-31 11:00:38 -04:00
Fedora Release Engineering 6b90d8ec0b - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-07-28 06:23:25 +00:00
Miro Hrončok ab3d82cbb9 Add lua(abi) requirements generator (requires RPM 4.16+)
Any package that installs to /usr/lib(64)/lua/X.Y/ or /usr/share/lua/X.Y/
will require lua(abi) = X.Y.

Co-own the RPM directories to avoid a dependency on RPM (or not owned directory).
2020-07-01 01:26:06 +02:00
Tom Callaway 18ba6592c3 merge 2020-06-29 13:57:48 -04:00
Tom Callaway 627e03f462 5.4.0 2020-06-29 13:56:50 -04:00
Fedora Release Engineering 9898d3a2b9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-29 11:24:13 +00:00
Fedora Release Engineering 79c4e48904 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-25 15:18:04 +00:00
Igor Gnatenko 25c08789fb Rebuild for readline 8.0 2019-02-17 09:30:51 +01:00
Fedora Release Engineering a8f0bdcdb6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-01 09:07:07 +00:00
Igor Gnatenko 3e022d9430 Remove obsolete Group tag
References: https://fedoraproject.org/wiki/Changes/Remove_Group_Tag
2019-01-28 20:24:14 +01:00
Tom Callaway b7b7312e06 apply fix for CVE-2019-6706 (bz1670020) 2019-01-28 09:29:21 -05:00
Petr Špaček bc0f275b1e
move ownership of /usr/share/lua/5.3 and /usr/lib64/lua/5.3 to lua-libs
As far as I can tell there should not be any effect visible outside of
RPM database and fedora-review tool.

This change is needed to make lua-libs package + *other* Lua packages
compliant with packaging guidelines.

Formerly the lua-libs package put a library /usr/lib64/lua/5.3 directory
but did not own the directory itself. This is being flagged by
fedora-review as non-compliance.

This problem affected other Lua packages which put library into
/usr/lib64/lua/5.3 as well. These other libraries were always flagged
by fedora-review as non-compliant because the library package did not
Require a package which owns /usr/lib64/lua/5.3.
(The build system autogenerates depedency on lua-libs which did not own
the directory.)
2018-07-18 12:28:45 +02:00
Fedora Release Engineering d10681a367 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-07-13 09:25:45 +00:00
Tom Callaway 6edfe7dba9 5.3.5 2018-07-10 13:31:57 -04:00
Tom Callaway ed24e54f3b move lua(abi) provide to -libs, add fix for bug 6 2018-02-13 10:23:53 -05:00
Fedora Release Engineering 6bf1d36134 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-02-08 00:18:17 +00:00
Richard W.M. Jones ebaf4c0957 Unnecessary change to RISC-V macros in GCC requires change in luaconf.h. 2018-01-02 15:59:24 +00:00
Tom Callaway 29f29bee30 fix pkgconfig provides (bz1519921) 2017-12-04 12:20:12 -05:00
Yevhenii Shapovalov 7b824e0268 add tests 2017-11-09 13:39:24 +02:00
Tom Callaway 8a0d515308 missing patch 2017-10-29 20:35:10 -04:00
Tom Callaway d78b71f63f apply known upstream bugfixes 2017-10-29 20:33:46 -04:00
Fedora Release Engineering 0b6e19e40a - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild 2017-08-03 02:47:53 +00:00
Fedora Release Engineering c603c23391 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild 2017-07-26 20:25:14 +00:00
Björn Esser 62bbfe64a1 Refactor macros to a more common syntax
Use rpm's build-in lua for macros
2017-05-28 10:48:02 +02:00
Björn Esser 9774218a76 Add rpm-macros file, providing packaging macros for lua add-ons (#1447324) 2017-05-24 15:53:59 +02:00
Tom Callaway b7447739b8 5.3.4 2017-02-09 10:12:44 -05:00
Igor Gnatenko 53e62ec64e Rebuild for readline 7.x
Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
2017-01-12 17:30:33 +01:00
Richard W.M. Jones 57dc5023ce luaconf.h: Add multilib support for RISC-V architecture.
Just a trivial change to make sure this doesn't break
when building the .riscv64.rpm package.
2016-09-10 09:48:01 +01:00
Tom Callaway 423087435d create lua-libs subpackage, disable bootstrap 2016-07-26 11:58:29 -04:00
Tom Callaway 0d4410908a create lua-libs subpackage, disable bootstrap 2016-07-26 11:55:11 -04:00
Tom Callaway 19e01a142e apply upstream fixes for bug 1 & 2 2016-07-25 16:08:19 -04:00
Tom Callaway d6b7c55828 5.3.3 2016-06-07 12:14:33 -04:00
Dennis Gilmore 4423d02921 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild 2016-02-04 04:31:39 +00:00
Tom Callaway dbe53f0986 fix multilib issues 2015-12-11 13:57:51 -05:00
d. johnson 81d07323db Update to 5.3.2 (#1039249,1173984) / Added upstream test suite to verify build 2015-12-10 23:44:46 -06:00
d. johnson 4861560d50 Update to 5.3.2 (#1039249,1173984) / Added upstream test suite to verify build 2015-12-10 23:42:01 -06:00
Jaromir Capik 48321fdc21 Adding STAGE2 bootstrap recipe
https://fedorahosted.org/fpc/ticket/529
2015-11-05 17:12:54 +01:00
Dennis Gilmore a049d77ce8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild 2015-06-17 19:03:12 +00:00
Kalev Lember 1d166ab1f9 Define LUA_COMPAT_5_2 in addition to LUA_COMPAT_5_1
https://bugzilla.redhat.com/show_bug.cgi?id=1204129
2015-03-20 11:56:31 +01:00
Till Maas 1b0764b470 Rebuilt for Fedora 23 Change
https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code
2015-02-21 22:15:46 +01:00
Tom Callaway 5ba464150d lua 5.3 (with 5.2 library as to not break the whole freaking universe while we rebuild things) 2015-01-16 10:14:21 -05:00
Tom Callaway 0e340ec150 5.2.3 2014-12-10 16:57:50 -05:00
Tom Callaway 80674c8fe9 5.2.3 2014-12-10 16:50:23 -05:00
Peter Robinson f76e1fe1c7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild 2014-08-17 07:52:21 +00:00
Tom Callaway a0a7266c5f fix license handling 2014-07-18 15:57:31 -04:00
Dennis Gilmore df145143cd - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild 2014-06-07 02:08:47 -05:00
Tom Callaway aa9c315347 readd and fix configure-compat-module.patch to use LUA_CONFIG_ALL instead 2013-10-23 17:12:32 +01:00
Tom Callaway 4722481a4d drop configure-compat-module.patch, if you really need old lua behavior, use compat-lua 2013-10-23 16:08:13 +01:00
Hans de Goede 68422ad970 Drop compat-lua-libs package, as there now is a separate compat-lua
package (including a -devel)
2013-08-05 22:10:14 +02:00
Dennis Gilmore c7fdd0a771 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild 2013-08-03 03:20:09 -05:00
Tom Callaway 44f7aeefd6 lua 5.2 2013-05-14 16:40:40 -04:00
Dennis Gilmore 8e864b6dbb - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild 2013-02-13 23:56:15 -06:00
Dennis Gilmore c2cdb5d5c6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild 2012-07-19 17:26:37 -05:00
Dennis Gilmore d36a7e5fc6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild 2012-01-13 02:59:54 -06:00
Tim Niemueller b079b31fe9 Provide lua(abi) = 5.1 for better distro updates later 2011-04-06 15:29:15 +02:00
Dennis Gilmore c30317b6b9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild 2011-02-08 08:06:21 -06:00
Tim Niemueller 48bc9e3034 lua f13: branch file removed 2011-01-29 11:49:19 +01:00
Tim Niemueller 79052831cb Merge branch 'master' into f13
Conflicts:
	.gitignore
2011-01-29 11:47:31 +01:00
Tim Niemueller aec7b633dd Update autotoolize patch, include Lua bugfix patch 2011-01-29 11:45:24 +01:00
Tim Niemueller c6e0c4483b Add IDSIZE patch for better error messages 2011-01-28 19:32:52 +01:00
Fedora Release Engineering 3310d8d4fd dist-git conversion 2010-10-07 00:55:16 +00:00
Fedora Release Engineering 88aaf9afda dist-git conversion 2010-10-07 00:54:47 +00:00
Tim Niemueller e9fe075726 Add patch regarding dlopen flags to support lunatic (Lua-Python bridge) 2010-05-09 10:46:41 +00:00
Jesse Keating 9b501b0c65 Initialize branch F-13 for lua 2010-02-17 01:58:51 +00:00
Bill Nottingham 12be6f1731 Fix typo that causes a failure to update the common directory. (releng #2781) 2009-11-25 23:51:37 +00:00
Jesse Keating 60eaf20644 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild 2009-07-25 11:23:42 +00:00
Tim Niemueller 5d2d9b903b Link liblua.so with -lm (math lib), fixes rhbz #499238 2009-06-11 22:37:45 +00:00
Jesse Keating fdffd8ee8c - Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild 2009-02-25 21:58:04 +00:00
Tim Niemueller 65ae3f8568 New upstream release 5.1.4 2008-09-03 12:27:53 +00:00
Tim Niemueller 3395d2ab39 Add -static subpackage with static liblua.a, fix for #445939 2008-05-12 16:59:32 +00:00
Tim Niemueller c32993b11a * Sun Apr 13 2008 Tim Niemueller <tim@niemueller.de> - 5.1.3-5
- Provide lua = 5.1, this way add-on packages can easily depend on the Lua
  base version and expect certain paths for packages
2008-04-13 20:39:17 +00:00
Hans de Goede e12c6412f0 * Sat Apr 5 2008 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.3-4
- Not only own $libdir/lua/5.1 and $datadir/lua/5.1 but also $libdir/lua
  and $datadir/lua for proper removal of these dirs upon lua removal
2008-04-05 07:24:12 +00:00
Tim Niemueller 76b6600768 own $libdir/lua/5.1 and $datadir/lua/5.1. These are the standard package
search path for Lua. Packaging them properly allows for easy creation of
Lua addon packages.

timn
2008-03-14 10:20:17 +00:00
Jesse Keating 8e0d0400e6 * Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 5.1.3-2
- Autorebuild for GCC 4.3
2008-02-19 09:11:48 +00:00
Hans de Goede 4c4144dc8d * Sat Jan 26 2008 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.3-1
- New upstream release 5.1.3
2008-01-26 23:07:49 +00:00
Hans de Goede 9892d09579 * Mon Nov 26 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.2-4
- Fix libdir in lua.pc being /usr/lib on x86_64 (bz 399101)
2007-11-26 08:44:36 +00:00
Hans de Goede 4ad1de21c2 * Sun Oct 21 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.2-3
- Also use lib64 instead of lib on ia64 and sparc64
2007-10-21 18:02:12 +00:00
Hans de Goede 81d929317c * Sun Oct 21 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.2-2
- Fix multilib condlict in luaconf.h (bz 342561)
2007-10-21 17:43:45 +00:00
46 changed files with 2730 additions and 56 deletions

View File

@ -1,2 +0,0 @@
lua-5.1.1-autotoolize.patch.gz
lua-5.1.2.tar.gz

27
.gitignore vendored Normal file
View File

@ -0,0 +1,27 @@
lua-5.1.4.tar.gz
lua-5.1.4/
.build*
*.src.rpm
/x86_64/
/i386/
/lua-5.2.2.tar.gz
/lua-5.2.3.tar.gz
/lua-5.3.0.tar.gz
/lua-5.3.2-tests.tar.gz
/lua-5.3.2.tar.gz
/lua-5.3.3.tar.gz
/lua-5.3.3-tests.tar.gz
/lua-5.3.4.tar.gz
/lua-5.3.4-tests.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

View 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)

View 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

View 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 */

View 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 */
}

View File

@ -0,0 +1,22 @@
--- a/src/lapi.c
+++ b/src/lapi.c
@@ -1285,14 +1285,14 @@ LUA_API void *lua_upvalueid (lua_State *
LUA_API void lua_upvaluejoin (lua_State *L, int fidx1, int n1,
int fidx2, int n2) {
- LClosure *f1;
- UpVal **up1 = getupvalref(L, fidx1, n1, &f1);
+ UpVal **up1 = getupvalref(L, fidx1, n1, NULL); /* the last parameter not needed */
UpVal **up2 = getupvalref(L, fidx2, n2, NULL);
+ if (*up1 == *up2) return; /* Already joined */
+ (*up2)->refcount++;
+ if (upisopen(*up2)) (*up2)->u.open.touched = 1;
+ luaC_upvalbarrier(L, *up2);
luaC_upvdeccount(L, *up1);
*up1 = *up2;
- (*up1)->refcount++;
- if (upisopen(*up1)) (*up1)->u.open.touched = 1;
- luaC_upvalbarrier(L, *up1);
}

View File

@ -1,21 +0,0 @@
# Makefile for source rpm: lua
# $Id$
NAME := lua
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

View 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;

View File

@ -0,0 +1,34 @@
diff -up lua-5.2.2/configure.ac.compat-module lua-5.2.2/configure.ac
--- lua-5.2.2/configure.ac.compat-module 2013-05-10 10:16:05.344137597 -0400
+++ lua-5.2.2/configure.ac 2013-05-10 10:16:05.357137596 -0400
@@ -11,6 +11,19 @@ AC_PROG_CC
AC_PROG_LIBTOOL
AC_ARG_WITH(
+ [compat-module],
+ [AC_HELP_STRING([--with-compat-module], [Enable LUA_COMPAT_MODULE functions [default=no]])],
+ [use_compat_module=$withval],
+ [use_compat_module=no]
+)
+
+COMPAT_DEFS="#undef LUA_COMPAT_ALL"
+if test "x$use_compat_module" == "xyes"; then
+ COMPAT_DEFS="#define LUA_COMPAT_ALL"
+fi
+AC_SUBST(COMPAT_DEFS)
+
+AC_ARG_WITH(
[readline],
[AC_HELP_STRING([--with-readline], [Use readline for interpreter input [default=yes]])],
[use_readline=$withval],
diff -up lua-5.2.2/src/luaconf.h.template.in.compat-module lua-5.2.2/src/luaconf.h.template.in
--- lua-5.2.2/src/luaconf.h.template.in.compat-module 2013-05-10 10:25:42.586116963 -0400
+++ lua-5.2.2/src/luaconf.h.template.in 2013-05-10 10:26:29.957115269 -0400
@@ -15,6 +15,7 @@
@LUA_DL_DEFS@
@LUA_BUILD_AS_DLL_DEFS@
@READLINE_DEFS@
+@COMPAT_DEFS@
/*

View File

@ -0,0 +1,22 @@
diff -up lua-5.2.2/configure.ac.linux lua-5.2.2/configure.ac
--- lua-5.2.2/configure.ac.linux 2013-05-10 15:42:27.269437631 -0400
+++ lua-5.2.2/configure.ac 2013-05-10 15:43:23.530435620 -0400
@@ -50,6 +50,7 @@ AC_SUBST(READLINE_LIBS)
case "$host" in
*-mingw*) use_os=win32 ;;
*-darwin*) use_os=macosx ;;
+ *-linux*) use_os=linux ;;
*) use_os=posix ;;
esac
@@ -62,6 +63,10 @@ if test "x$use_os" == "xwin32"; then
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" == "xlinux"; then
+ POSIX_DEFS="#define LUA_USE_LINUX"
+ LUA_DL_DEFS="#define LUA_DL_DLOPEN"
+ LUA_LIBS="$LUA_LIBS -ldl"
elif test "x$use_os" == "xposix"; then
POSIX_DEFS="#define LUA_USE_POSIX"
LUA_DL_DEFS="#define LUA_DL_DLOPEN"

13
lua-5.2.2-idsize.patch Normal file
View File

@ -0,0 +1,13 @@
diff --git a/src/luaconf.h.template.in b/src/luaconf.h.template.in
index a427c53..6f1d567 100644
--- a/src/luaconf.h.template.in
+++ b/src/luaconf.h.template.in
@@ -206,7 +206,7 @@
@* of a function in debug information.
** CHANGE it if you want a different size.
*/
-#define LUA_IDSIZE 60
+#define LUA_IDSIZE 512
/*

View File

@ -0,0 +1,54 @@
diff -up lua-5.2.2/src/lopcodes.c.luac-shared lua-5.2.2/src/lopcodes.c
--- lua-5.2.2/src/lopcodes.c.luac-shared 2012-05-14 09:34:18.000000000 -0400
+++ lua-5.2.2/src/lopcodes.c 2013-05-09 14:36:30.874581104 -0400
@@ -14,7 +14,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",
@@ -61,7 +61,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.2.2/src/lopcodes.h.luac-shared lua-5.2.2/src/lopcodes.h
--- lua-5.2.2/src/lopcodes.h.luac-shared 2013-05-09 14:37:14.718581762 -0400
+++ lua-5.2.2/src/lopcodes.h 2013-05-09 14:37:40.998582156 -0400
@@ -269,7 +269,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))
@@ -278,7 +278,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.2.2/src/lundump.h.luac-shared lua-5.2.2/src/lundump.h
--- lua-5.2.2/src/lundump.h.luac-shared 2012-05-08 09:53:33.000000000 -0400
+++ lua-5.2.2/src/lundump.h 2013-05-09 14:36:30.874581104 -0400
@@ -17,7 +17,7 @@ LUAI_FUNC Closure* luaU_undump (lua_Stat
LUAI_FUNC void luaU_header (lu_byte* h);
/* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
/* data to catch conversion errors */
#define LUAC_TAIL "\x19\x93\r\n\x1a\n"

204
lua-5.2.3-autotoolize.patch Normal file
View File

@ -0,0 +1,204 @@
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..8d968c4
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = src doc
+
+EXTRA_DIST = README
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..3af6625
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,69 @@
+AC_PREREQ(2.59)
+AC_INIT([lua], [5.2.3], [https://bugzilla.redhat.com/], [lua-at], [http://www.lua.org])
+AC_SUBST([MAJOR_VERSION], [5.2])
+
+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 --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..3705696
--- /dev/null
+++ b/doc/Makefile.am
@@ -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 --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..0abd9dd
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,5 @@
+lua
+lua.pc
+luac
+luaconf.h
+luaconf.h.template
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..6c7c79f
--- /dev/null
+++ b/src/Makefile.am
@@ -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 lbitlib.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 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 $@
diff --git a/src/lua.pc.in b/src/lua.pc.in
new file mode 100644
index 0000000..25faa8d
--- /dev/null
+++ b/src/lua.pc.in
@@ -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 --git a/src/luaconf.h b/src/luaconf.h.template.in
--- a/src/luaconf.h.template.in
+++ b/src/luaconf.h.template.in
@@ -11,6 +11,11 @@
#include <limits.h>
#include <stddef.h>
+@POSIX_DEFS@
+@LUA_DL_DEFS@
+@LUA_BUILD_AS_DLL_DEFS@
+@READLINE_DEFS@
+
/*
** ==================================================================
@@ -100,9 +105,9 @@
#else /* }{ */
#define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/"
-#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
#define LUA_PATH_DEFAULT \
LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" "./?.lua"

192
lua-5.3.0-autotoolize.patch Normal file
View File

@ -0,0 +1,192 @@
diff -up lua-5.3.0/configure.ac.autoxxx lua-5.3.0/configure.ac
--- lua-5.3.0/configure.ac.autoxxx 2015-01-15 10:20:03.826889574 -0500
+++ lua-5.3.0/configure.ac 2015-01-15 10:20:03.826889574 -0500
@@ -0,0 +1,69 @@
+AC_PREREQ(2.59)
+AC_INIT([lua], [5.3.0], [https://bugzilla.redhat.com/], [lua-at], [http://www.lua.org])
+AC_SUBST([MAJOR_VERSION], [5.3])
+
+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.3.0/doc/Makefile.am.autoxxx lua-5.3.0/doc/Makefile.am
--- lua-5.3.0/doc/Makefile.am.autoxxx 2015-01-15 10:20:03.826889574 -0500
+++ lua-5.3.0/doc/Makefile.am 2015-01-15 10:20:03.826889574 -0500
@@ -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.3.0/Makefile.am.autoxxx lua-5.3.0/Makefile.am
--- lua-5.3.0/Makefile.am.autoxxx 2015-01-15 10:20:03.826889574 -0500
+++ lua-5.3.0/Makefile.am 2015-01-15 10:20:03.826889574 -0500
@@ -0,0 +1,3 @@
+SUBDIRS = src doc
+
+EXTRA_DIST = README
diff -up lua-5.3.0/src/.gitignore.autoxxx lua-5.3.0/src/.gitignore
--- lua-5.3.0/src/.gitignore.autoxxx 2015-01-15 10:20:03.826889574 -0500
+++ lua-5.3.0/src/.gitignore 2015-01-15 10:20:03.826889574 -0500
@@ -0,0 +1,5 @@
+lua
+lua.pc
+luac
+luaconf.h
+luaconf.h.template
diff -up lua-5.3.0/src/luaconf.h.template.in.autoxxx lua-5.3.0/src/luaconf.h.template.in
--- lua-5.3.0/src/luaconf.h.template.in.autoxxx 2015-01-15 10:20:03.828889562 -0500
+++ lua-5.3.0/src/luaconf.h.template.in 2015-01-15 10:22:37.420027778 -0500
@@ -11,6 +11,11 @@
#include <limits.h>
#include <stddef.h>
+@POSIX_DEFS@
+@LUA_DL_DEFS@
+@LUA_BUILD_AS_DLL_DEFS@
+@READLINE_DEFS@
+
/*
** ===================================================================
@@ -175,9 +180,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 "/"
#define LUA_PATH_DEFAULT \
LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \
diff -up lua-5.3.0/src/lua.pc.in.autoxxx lua-5.3.0/src/lua.pc.in
--- lua-5.3.0/src/lua.pc.in.autoxxx 2015-01-15 10:20:03.827889568 -0500
+++ lua-5.3.0/src/lua.pc.in 2015-01-15 10:20:03.827889568 -0500
@@ -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.3.0/src/Makefile.am.autoxxx lua-5.3.0/src/Makefile.am
--- lua-5.3.0/src/Makefile.am.autoxxx 2015-01-15 10:20:03.826889574 -0500
+++ lua-5.3.0/src/Makefile.am 2015-01-15 10:20:03.826889574 -0500
@@ -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 lbitlib.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 $@

View File

@ -0,0 +1,35 @@
diff -up lua-5.2.2/configure.ac.compat-module lua-5.2.2/configure.ac
--- lua-5.2.2/configure.ac.compat-module 2013-05-10 10:16:05.344137597 -0400
+++ lua-5.2.2/configure.ac 2013-05-10 10:16:05.357137596 -0400
@@ -11,6 +11,20 @@ AC_PROG_CC
AC_PROG_LIBTOOL
AC_ARG_WITH(
+ [compat-module],
+ [AC_HELP_STRING([--with-compat-module], [Enable LUA_COMPAT_MODULE functions [default=no]])],
+ [use_compat_module=$withval],
+ [use_compat_module=no]
+)
+
+COMPAT_DEFS="#undef LUA_COMPAT_ALL"
+if test "x$use_compat_module" == "xyes"; then
+ COMPAT_DEFS="#define LUA_COMPAT_5_1
+#define LUA_COMPAT_5_2"
+fi
+AC_SUBST(COMPAT_DEFS)
+
+AC_ARG_WITH(
[readline],
[AC_HELP_STRING([--with-readline], [Use readline for interpreter input [default=yes]])],
[use_readline=$withval],
diff -up lua-5.2.2/src/luaconf.h.template.in.compat-module lua-5.2.2/src/luaconf.h.template.in
--- lua-5.2.2/src/luaconf.h.template.in.compat-module 2013-05-10 10:25:42.586116963 -0400
+++ lua-5.2.2/src/luaconf.h.template.in 2013-05-10 10:26:29.957115269 -0400
@@ -15,6 +15,7 @@
@LUA_DL_DEFS@
@LUA_BUILD_AS_DLL_DEFS@
@READLINE_DEFS@
+@COMPAT_DEFS@
/*

12
lua-5.3.0-idsize.patch Normal file
View File

@ -0,0 +1,12 @@
diff -up lua-5.3.0/src/luaconf.h.template.in.idsize lua-5.3.0/src/luaconf.h.template.in
--- lua-5.3.0/src/luaconf.h.template.in.idsize 2015-01-15 10:23:20.515801344 -0500
+++ lua-5.3.0/src/luaconf.h.template.in 2015-01-15 10:23:48.955651916 -0500
@@ -693,7 +693,7 @@
@@ of a function in debug information.
** CHANGE it if you want a different size.
*/
-#define LUA_IDSIZE 60
+#define LUA_IDSIZE 512
/*

12
lua-5.3.4-bug1.patch Normal file
View File

@ -0,0 +1,12 @@
diff -up lua-5.3.4/src/lparser.c.bug1 lua-5.3.4/src/lparser.c
--- lua-5.3.4/src/lparser.c.bug1 2017-08-02 16:03:43.730247916 -0400
+++ lua-5.3.4/src/lparser.c 2017-08-02 16:03:56.507957260 -0400
@@ -1392,7 +1392,7 @@ static void test_then_block (LexState *l
luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */
enterblock(fs, &bl, 0); /* must enter block before 'goto' */
gotostat(ls, v.t); /* handle goto/break */
- skipnoopstat(ls); /* skip other no-op statements */
+ while (testnext(ls, ';')) {} /* skip colons */
if (block_follow(ls, 0)) { /* 'goto' is the entire block? */
leaveblock(fs);
return; /* and that is it */

11
lua-5.3.4-bug4.patch Normal file
View File

@ -0,0 +1,11 @@
diff -up lua-5.3.4/src/ldebug.c.bug4 lua-5.3.4/src/ldebug.c
--- lua-5.3.4/src/ldebug.c.bug4 2017-08-02 16:05:36.985671687 -0400
+++ lua-5.3.4/src/ldebug.c 2017-08-02 16:05:55.257256062 -0400
@@ -653,6 +653,7 @@ l_noret luaG_runerror (lua_State *L, con
CallInfo *ci = L->ci;
const char *msg;
va_list argp;
+ luaC_checkGC(L); /* error message uses memory */
va_start(argp, fmt);
msg = luaO_pushvfstring(L, fmt, argp); /* format message */
va_end(argp);

14
lua-5.3.4-bug5.patch Normal file
View File

@ -0,0 +1,14 @@
diff -up lua-5.3.4/src/lgc.c.bug5 lua-5.3.4/src/lgc.c
--- lua-5.3.4/src/lgc.c.bug5 2017-10-29 20:30:18.824283152 -0400
+++ lua-5.3.4/src/lgc.c 2017-10-29 20:31:12.133021523 -0400
@@ -643,8 +643,9 @@ static void clearkeys (global_State *g,
for (n = gnode(h, 0); n < limit; n++) {
if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) {
setnilvalue(gval(n)); /* remove value ... */
- removeentry(n); /* and remove entry from table */
}
+ if (ttisnil(gval(n))) /* is entry empty? */
+ removeentry(n); /* remove entry from table */
}
}
}

23
lua-5.3.4-bug6.patch Normal file
View File

@ -0,0 +1,23 @@
diff -up lua-5.3.4/src/lapi.c.bug6 lua-5.3.4/src/lapi.c
--- lua-5.3.4/src/lapi.c.bug6 2018-02-13 10:18:59.386451581 -0500
+++ lua-5.3.4/src/lapi.c 2018-02-13 10:19:42.700575448 -0500
@@ -533,6 +533,7 @@ LUA_API void lua_pushcclosure (lua_State
lua_lock(L);
if (n == 0) {
setfvalue(L->top, fn);
+ api_incr_top(L);
}
else {
CClosure *cl;
@@ -546,9 +547,9 @@ LUA_API void lua_pushcclosure (lua_State
/* does not need barrier because closure is white */
}
setclCvalue(L, L->top, cl);
+ api_incr_top(L);
+ luaC_checkGC(L);
}
- api_incr_top(L);
- luaC_checkGC(L);
lua_unlock(L);
}

View 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));

View 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

View 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 $@

View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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;
}

458
lua.spec
View File

@ -1,14 +1,56 @@
%global major_version 5.4
# Normally, this is the same as version, but... not always.
%global test_version 5.4.4
# 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
# everything will grind to a halt.
%global bootstrap 1
%global bootstrap_major_version 5.3
%global bootstrap_version %{bootstrap_major_version}.6
# Place rpm-macros into proper location.
%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
Name: lua
Version: 5.1.2
Release: 1%{?dist}
Version: %{major_version}.4
Release: 4%{?dist}
Summary: Powerful light-weight programming language
Group: Development/Languages
License: MIT
URL: http://www.lua.org/
Source0: http://www.lua.org/ftp/lua-%{version}.tar.gz
Patch0: lua-5.1.1-autotoolize.patch.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: readline-devel ncurses-devel
URL: https://www.lua.org/
Source0: https://www.lua.org/ftp/lua-%{version}.tar.gz
# copied from doc/readme.html on 2014-07-18
Source1: mit.txt
%if 0%{?bootstrap}
Source2: https://www.lua.org/ftp/lua-%{bootstrap_version}.tar.gz
%endif
Source3: https://www.lua.org/tests/lua-%{test_version}-tests.tar.gz
# multilib
Source4: luaconf.h
Patch0: %{name}-5.4.0-beta-autotoolize.patch
Patch1: %{name}-5.3.0-idsize.patch
#Patch2: %%{name}-5.3.0-luac-shared-link-fix.patch
Patch3: %{name}-5.2.2-configure-linux.patch
Patch4: %{name}-5.3.0-configure-compat-module.patch
%if 0%{?bootstrap}
Patch5: %{name}-5.3.0-autotoolize.patch
Patch6: %{name}-5.3.5-luac-shared-link-fix.patch
%endif
# 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: make
Requires: lua-libs = %{version}-%{release}
%description
Lua is a powerful light-weight programming language designed for
@ -20,61 +62,415 @@ is dynamically typed, interpreted from bytecodes, and has automatic
memory management with garbage collection, making it ideal for
configuration, scripting, and rapid prototyping.
%package devel
Summary: Development files for %{name}
Group: System Environment/Libraries
Requires: %{name} = %{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
%description devel
This package contains development files for %{name}.
%package libs
Summary: Libraries for %{name}
Provides: lua(abi) = %{major_version}
%description libs
This package contains the shared libraries for %{name}.
%package static
Summary: Static library for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description static
This package contains the static version of liblua for %{name}.
%prep
%setup -q
%if 0%{?bootstrap}
%setup -q -a 2 -a 3 -n %{name}-%{version}
%else
%setup -q -a 3
%endif
cp %{SOURCE1} .
mv src/luaconf.h src/luaconf.h.template.in
%patch0 -p1 -E -z .autoxxx
# fix perms on auto files
chmod u+x autogen.sh config.guess config.sub configure depcomp install-sh missing
%patch1 -p1 -z .idsize
#%% patch2 -p1 -z .luac-shared
%patch3 -p1 -z .configure-linux
%patch4 -p1 -z .configure-compat-all
%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
sed -i 's|5.3.0|%{version}|g' configure.ac
autoreconf -ifv
%if 0%{?bootstrap}
cd lua-%{bootstrap_version}/
mv src/luaconf.h src/luaconf.h.template.in
%patch5 -p1 -b .autoxxx
%patch1 -p1 -b .idsize
%patch3 -p1 -z .configure-linux
%patch4 -p1 -z .configure-compat-all
%patch6 -p1 -b .luac-shared-link-fix
autoreconf -i
cd ..
%endif
%build
%configure --with-readline
%configure --with-readline --with-compat-module
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
# Autotools give me a headache sometimes.
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
# only one which needs this and otherwise we get License troubles
make %{?_smp_mflags} LIBS="-ldl" luac_LDADD="liblua.la -lm -ldl"
# also remove readline from lua.pc
sed -i 's/-lreadline -lncurses //g' etc/lua.pc
%make_build LIBS="-lm -ldl"
# only /usr/bin/lua links with readline now #luac_LDADD="liblua.la -lm -ldl"
%if 0%{?bootstrap}
pushd lua-%{bootstrap_version}
%configure --with-readline --with-compat-module
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
# Autotools give me a headache sometimes.
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
# only one which needs this and otherwise we get License troubles
%make_build LIBS="-lm -ldl" luac_LDADD="liblua.la -lm -ldl"
popd
%endif
%check
cd ./lua-%{test_version}-tests/
# Dont skip the fully portable or ram-hungry tests:
# sed -i.orig -e '
# /attrib.lua/d;
# /files.lua/d;
# /db.lua/d;
# /errors.lua/d;
# ' all.lua
# LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{_libdir} $RPM_BUILD_ROOT/%{_bindir}/lua all.lua
# Removing tests that fail under mock/koji
sed -i.orig -e '
/db.lua/d;
/errors.lua/d;
' all.lua
LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{_libdir} $RPM_BUILD_ROOT/%{_bindir}/lua -e"_U=true" all.lua
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
rm $RPM_BUILD_ROOT%{_libdir}/*.{la,a}
%make_install
rm $RPM_BUILD_ROOT%{_libdir}/*.la
mkdir -p $RPM_BUILD_ROOT%{_libdir}/lua/%{major_version}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/lua/%{major_version}
# Rename luaconf.h to luaconf-<arch>.h to avoid file conflicts on
# multilib systems and install luaconf.h wrapper
mv %{buildroot}%{_includedir}/luaconf.h %{buildroot}%{_includedir}/luaconf-%{_arch}.h
install -p -m 644 %{SOURCE4} %{buildroot}%{_includedir}/luaconf.h
%clean
rm -rf $RPM_BUILD_ROOT
%if 0%{?bootstrap}
pushd lua-%{bootstrap_version}
mkdir $RPM_BUILD_ROOT/installdir
make install DESTDIR=$RPM_BUILD_ROOT/installdir
cp -a $RPM_BUILD_ROOT/installdir/%{_libdir}/liblua-%{bootstrap_major_version}.so $RPM_BUILD_ROOT%{_libdir}/
mkdir -p $RPM_BUILD_ROOT%{_libdir}/lua/%{bootstrap_major_version}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/lua/%{bootstrap_major_version}
rm -rf $RPM_BUILD_ROOT/installdir
popd
%endif
%files
%defattr(-,root,root,-)
%doc COPYRIGHT HISTORY README doc/*.html doc/*.css doc/*.gif doc/*.png
%{_bindir}/lua*
%{_libdir}/liblua-*.so
%{!?_licensedir:%global license %%doc}
%license mit.txt
%doc README doc/*.html doc/*.css doc/*.gif doc/*.png
%{_bindir}/lua
%{_bindir}/luac
%{_mandir}/man1/lua*.1*
%files libs
%dir %{_libdir}/lua
%dir %{_libdir}/lua/%{major_version}
%{_libdir}/liblua-%{major_version}.so
%dir %{_datadir}/lua
%dir %{_datadir}/lua/%{major_version}
%if 0%{?bootstrap}
%dir %{_libdir}/lua/%{bootstrap_major_version}
%{_libdir}/liblua-%{bootstrap_major_version}.so
%dir %{_datadir}/lua/%{bootstrap_major_version}
%endif
%files devel
%defattr(-,root,root,-)
%{_includedir}/l*.h
%{_includedir}/l*.hpp
%{_libdir}/liblua.so
%{_libdir}/pkgconfig/*.pc
%files static
%{_libdir}/*.a
%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
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.5-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Feb 17 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 5.3.5-5
- Rebuild for readline 8.0
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Jan 28 2019 Tom Callaway <spot@fedoraproject.org> - 5.3.5-3
- apply fix for CVE-2019-6706 (bz1670020)
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jul 10 2018 Tom Callaway <spot@fedoraproject.org> - 5.3.5-1
- update to 5.3.5
* Tue Feb 13 2018 Tom Callaway <spot@fedoraproject.org> - 5.3.4-10
- move lua(abi) provide to -libs
- add fix for bug 6
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.4-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Tue Jan 2 2018 Richard W.M. Jones <rjones@redhat.com> - 5.3.4-8
- Unnecessary change to RISC-V macros in GCC requires change in luaconf.h.
* Mon Dec 4 2017 Tom Callaway <spot@fedoraproject.org> - 5.3.4-7
- fix pkgconfig provides (bz1519921)
* Sun Oct 29 2017 Tom Callaway <spot@fedoraproject.org> - 5.3.4-6
- apply known upstream bugfixes
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Sun May 28 2017 Björn Esser <besser82@fedoraproject.org> - 5.3.4-3
- Refactor macros to a more common syntax
- Use rpm's build-in lua for macros
* Wed May 24 2017 Björn Esser <besser82@fedoraproject.org> - 5.3.4-2
- Add rpm-macros file, providing packaging macros for lua add-ons (#1447324)
* Thu Feb 9 2017 Tom Callaway <spot@fedoraproject.org> 5.3.4-1
- update to 5.3.4
* Thu Jan 12 2017 Igor Gnatenko <ignatenko@redhat.com> - 5.3.3-4
- Rebuild for readline 7.x
* Tue Jul 26 2016 Tom Callaway <spot@fedoraproject.org> - 5.3.3-3
- create lua-libs subpackage
- disable bootstrap
* Mon Jul 25 2016 Tom Callaway <spot@fedoraproject.org> - 5.3.3-2
- apply fixes for upstream bug 1 & 2
* Tue Jun 7 2016 Tom Callaway <spot@fedoraproject.org> - 5.3.3-1
- update to 5.3.3
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Fri Dec 11 2015 Tom Callaway <spot@fedoraproject.org> - 5.3.2-2
- fix multilib support (#1229992)
* Fri Dec 11 2015 "D. Johnson" <fenris02@fedoraproject.org> - 5.3.2-1
- Update to 5.3.2 (#1039249,1173984)
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Fri Mar 20 2015 Kalev Lember <kalevlember@gmail.com> - 5.3.0-3
- Define LUA_COMPAT_5_2 in addition to LUA_COMPAT_5_1 (#1204129)
* Sat Feb 21 2015 Till Maas <opensource@till.name> - 5.3.0-2
- Rebuilt for Fedora 23 Change
https://fedoraproject.org/wiki/Changes/Harden_all_packages_with_position-independent_code
* Thu Jan 15 2015 Tom Callaway <spot@fedoraproject.org> - 5.3.0-1
- update to 5.3.0
- add bootstrapping glue
* Wed Dec 10 2014 Tom Callaway <spot@fedoraproject.org> - 5.2.3-1
- update to 5.2.3
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.2.2-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Fri Jul 18 2014 Tom Callaway <spot@fedoraproject.org> - 5.2.2-7
- fix license handling
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.2.2-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Wed Oct 23 2013 Tom Callaway <spot@fedoraproject.org> - 5.2.2-5
- readd and fix configure-compat-module.patch to use LUA_CONFIG_ALL instead
* Wed Oct 23 2013 Tom Callaway <spot@fedoraproject.org> - 5.2.2-4
- drop configure-compat-module.patch, if you really need old lua behavior, use compat-lua
* Mon Aug 05 2013 Hans de Goede <hdegoede@redhat.com> - 5.2.2-3
- Drop compat-lua-libs package, as there now is a separate compat-lua
package (including a -devel)
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.2.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Thu Apr 11 2013 Tom Callaway <spot@fedoraproject.org> - 5.2.2-1
- update to 5.2.2
- incorporate Aaron Faanes's changes
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1.4-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1.4-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1.4-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Wed Apr 06 2011 Tim Niemueller <tim@niemueller.de> - 5.1.4-9
- Provide lua(abi) = 5.1 for better distro updates later
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1.4-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Fri Jan 28 2011 Tim Niemueller <tim@niemueller.de> - 5.1.4-7
- Add patch to from lua.org with smaller bugfixes
- sed -i -e 's/5\.1\.3/5.1.4/g' on autotoolize patch, bug #641144
* Fri Jan 28 2011 Tim Niemueller <tim@niemueller.de> - 5.1.4-6
- Add patch to increase IDSIZE for more useful error messages
* Sun May 09 2010 Tim Niemueller <tim@niemueller.de> - 5.1.4-5
- Add patch regarding dlopen flags to support Lunatic (Lua-Python bridge)
* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Thu Jun 11 2009 Tim Niemueller <tim@niemueller.de> - 5.1.4-2
- Link liblua.so with -lm (math lib), fixes rhbz #499238
* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 5.1.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
* Wed Sep 03 2008 Tim Niemueller <tim@niemueller.de> - 5.1.4-1
- New upstream release 5.1.4
* Mon May 12 2008 Tim Niemueller <tim@niemueller.de> - 5.1.3-6
- Add -static subpackage with static liblua, fixes rh bug #445939
* Sun Apr 13 2008 Tim Niemueller <tim@niemueller.de> - 5.1.3-5
- Provide lua = 5.1, this way add-on packages can easily depend on the Lua
base version and expect certain paths for packages
* Sat Apr 5 2008 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.3-4
- Not only own $libdir/lua/5.1 and $datadir/lua/5.1 but also $libdir/lua
and $datadir/lua for proper removal of these dirs upon lua removal
* Fri Mar 14 2008 Tim Niemueller <tim@niemueller.de> - 5.1.3-3
- own $libdir/lua/5.1 and $datadir/lua/5.1. These are the standard package
search path for Lua. Packaging them properly allows for easy creation of
Lua addon packages.
* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 5.1.3-2
- Autorebuild for GCC 4.3
* Sat Jan 26 2008 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.3-1
- New upstream release 5.1.3
* Mon Nov 26 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.2-4
- Fix libdir in lua.pc being /usr/lib on x86_64 (bz 399101)
* Sun Oct 21 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.2-3
- Also use lib64 instead of lib on ia64 and sparc64
* Sun Oct 21 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.2-2
- Fix multilib condlict in luaconf.h (bz 342561)
* Mon Apr 2 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 5.1.2-1
- New upstream release 5.1.2
- Fix use of rpath on x86_64
@ -92,7 +488,7 @@ rm -rf $RPM_BUILD_ROOT
- New upstream release 5.1.1
- Fix detection of readline during compile (iow add readline support back)
* Mon Aug 27 2006 Michael J. Knox <michael[AT]knox.net.nz> - 5.1-7
* Sun Aug 27 2006 Michael J. Knox <michael[AT]knox.net.nz> - 5.1-7
- Rebuild for FC6
* Thu Jun 08 2006 Michael J. Knox <michael[AT]knox.net.nz> - 5.1-6
@ -120,7 +516,7 @@ rm -rf $RPM_BUILD_ROOT
* Sun May 22 2005 Jeremy Katz <katzj@redhat.com> - 5.0.2-4
- rebuild on all arches
* Fri Apr 7 2005 Michael Schwendt <mschwendt[AT]users.sf.net> - 5.0.2-3
* Thu Apr 7 2005 Michael Schwendt <mschwendt[AT]users.sf.net> - 5.0.2-3
- rebuilt
* Sat Feb 12 2005 David Woodhouse <dwmw2@infradead.org> - 5.0.2-2

61
luaconf.h Normal file
View File

@ -0,0 +1,61 @@
/*
* This luaconf.h is a wrapper include file for the original luaconf.h,
* which has been renamed to luaconf-<arch>.h. There are conflicts for the
* original luaconf.h on multilib systems, which result from arch-specific
* configuration options. Please do not use the arch-specific file directly.
*
* Copyright (C) 2015 Tom Callaway <spot@fedoraproject.org>
*/
/**
* \file luaconf.h
*/
#ifdef luaconf_wrapper_h
#error "luaconf_wrapper_h should not be defined!"
#endif
#define luaconf_wrapper_h
#if defined(__i386__)
#include "luaconf-i386.h"
#elif defined(__ia64__)
#include "luaconf-ia64.h"
#elif defined(__powerpc64__)
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#include "luaconf-ppc64.h"
# else
#include "luaconf-ppc64le.h"
# endif
#elif defined(__powerpc__)
#include "luaconf-ppc.h"
#elif defined(__s390x__)
#include "luaconf-s390x.h"
#elif defined(__s390__)
#include "luaconf-s390.h"
#elif defined(__x86_64__)
#include "luaconf-x86_64.h"
#elif defined(__arm__)
#include "luaconf-arm.h"
#elif defined(__alpha__)
#include "luaconf-alpha.h"
#elif defined(__sparc__) && defined (__arch64__)
#include "luaconf-sparc64.h"
#elif defined(__sparc__)
#include "luaconf-sparc.h"
#elif defined(__aarch64__)
#include "luaconf-aarch64.h"
#elif defined(__mips64) && defined(__MIPSEL__)
#include "luaconf-mips64el.h"
#elif defined(__mips64)
#include "luaconf-mips64.h"
#elif defined(__mips) && defined(__MIPSEL__)
#include "luaconf-mipsel.h"
#elif defined(__mips)
#include "luaconf-mips.h"
#elif defined(__riscv)
#include "luaconf-riscv64.h"
#else
#error "The lua-devel package is not usable with the architecture."
#endif
#undef luaconf_wrapper_h

19
mit.txt Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 1994-2013 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,2 +1,3 @@
751d2dfd522941e82571195aa81abe4c lua-5.1.1-autotoolize.patch.gz
687ce4c2a1ddff18f1008490fdc4e5e0 lua-5.1.2.tar.gz
SHA512 (lua-5.4.4.tar.gz) = af0c35d5ba00fecbb2dd617bd7b825edf7418a16a73076e04f2a0df58cdbf098dc3ff4402e974afd789eb5d86d2e12ec6df9c84b99b23656ea694a85f83bcd21
SHA512 (lua-5.4.4-tests.tar.gz) = 08b3d764b3f362a2cddf5a23e71b16eea96a234a970fa0048bab358ebbd77f99d9bd132af12254383c5bb5426516e1ce2107e529e88d3963869255f5a41198ef
SHA512 (lua-5.3.6.tar.gz) = ccc380d5e114d54504de0bfb0321ca25ec325d6ff1bfee44b11870b660762d1a9bf120490c027a0088128b58bb6b5271bbc648400cab84d2dc22b512c4841681

3
tests/README.md Normal file
View File

@ -0,0 +1,3 @@
# lua
lua tests

63
tests/Smoke/Makefile Normal file
View File

@ -0,0 +1,63 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /CoreOS/lua/Sanity/Smoke
# Description: Basic smoke for lua component
# Author: Stepan Sigut <ssigut@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export TEST=/CoreOS/lua/Sanity/Smoke
export TESTVERSION=1.0
BUILT_FILES=
FILES=$(METADATA) runtest.sh Makefile PURPOSE *.lua
.PHONY: all install download clean
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES)
test -x runtest.sh || chmod a+x runtest.sh
clean:
rm -f *~ $(BUILT_FILES)
include /usr/share/rhts/lib/rhts-make.include
$(METADATA): Makefile
@echo "Owner: Stepan Sigut <ssigut@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Basic smoke for lua component" >> $(METADATA)
@echo "Type: Sanity" >> $(METADATA)
@echo "TestTime: 5m" >> $(METADATA)
@echo "RunFor: lua" >> $(METADATA)
@echo "Requires: lua" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)
rhts-lint $(METADATA)

3
tests/Smoke/PURPOSE Normal file
View File

@ -0,0 +1,3 @@
PURPOSE of /CoreOS/lua/Sanity/Smoke
Description: Basic smoke for lua component
Author: Stepan Sigut <ssigut@redhat.com>

35
tests/Smoke/account.lua Normal file
View File

@ -0,0 +1,35 @@
-- account.lua
-- from PiL 1, Chapter 16
Account = {balance = 0}
function Account:new (o, name)
o = o or {name=name}
setmetatable(o, self)
self.__index = self
return o
end
function Account:deposit (v)
self.balance = self.balance + v
end
function Account:withdraw (v)
if v > self.balance then error("insufficient funds on account "..self.name) end
self.balance = self.balance - v
end
function Account:show (title)
print(title or "", self.name, self.balance)
end
a = Account:new(nil,"demo")
a:show("after creation")
a:deposit(1000.00)
a:show("after deposit")
a:withdraw(100.00)
a:show("after withdraw")
-- this would raise an error
b = Account:new(nil,"DEMO")
b:withdraw(100.00)

28
tests/Smoke/bisect.lua Normal file
View File

@ -0,0 +1,28 @@
-- bisect.lua
-- bisection method for solving non-linear equations
delta=1e-6 -- tolerance
function bisect(f,a,b,fa,fb)
local c=(a+b)/2
io.write(n," c=",c," a=",a," b=",b,"\n")
if c==a or c==b or math.abs(a-b)<delta then return c,b-a end
n=n+1
local fc=f(c)
if fa*fc<0 then return bisect(f,a,c,fa,fc) else return bisect(f,c,b,fc,fb) end
end
-- find root of f in the inverval [a,b]. needs f(a)*f(b)<0
function solve(f,a,b)
n=0
local z,e=bisect(f,a,b,f(a),f(b))
io.write(string.format("after %d steps, root is %.17g with error %.1e, f=%.1e\n",n,z,e,f(z)))
end
-- our function
function f(x)
return x*x*x-x-1
end
-- find zero in [1,2]
solve(f,1,2)

23
tests/Smoke/globals.lua Normal file
View File

@ -0,0 +1,23 @@
-- globals.lua
-- show all global variables
local seen={}
function dump(t,i)
seen[t]=true
local s={}
local n=0
for k in pairs(t) do
n=n+1 s[n]=k
end
table.sort(s)
for k,v in ipairs(s) do
print(i,v)
v=t[v]
if type(v)=="table" and not seen[v] then
dump(v,i.."\t")
end
end
end
dump(_G,"")

4
tests/Smoke/hello.lua Normal file
View File

@ -0,0 +1,4 @@
-- hello.lua
-- the first program in every language
io.write("Hello world, from ",_VERSION,"!\n")

70
tests/Smoke/runtest.sh Executable file
View File

@ -0,0 +1,70 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /CoreOS/lua/Sanity/Smoke
# Description: Basic smoke for lua component
# Author: Stepan Sigut <ssigut@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGES=${PACKAGES:-"lua"}
LUA=${LUA:-"lua"}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlAssertBinaryOrigin $LUA
set -o pipefail
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "cp *.lua $TmpDir"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "$LUA hello.lua 2>&1 | tee dump.log" 0
rlAssertGrep "Hello world, from Lua" "dump.log"
rlPhaseEnd
rlPhaseStartTest
rlRun "$LUA bisect.lua 2>&1 | tee dump.log" 0
rlAssertGrep "after 20 steps, root is 1.3247179985046387 with error 9.5e-07, f=1.8e-07" "dump.log"
rlPhaseEnd
rlPhaseStartTest
rlRun "$LUA globals.lua &>/dev/null" 0
rlPhaseEnd
rlPhaseStartTest
rlRun "$LUA account.lua 2>&1 | tee dump.log" 1
rlAssertGrep "after creation" "dump.log"
rlAssertGrep "lua: account.lua:18: insufficient funds on account DEMO" "dump.log"
rlPhaseEnd
rlPhaseStartTest
rlRun "$LUA sieve.lua &>/dev/null" 0
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd

28
tests/Smoke/sieve.lua Normal file
View File

@ -0,0 +1,28 @@
-- sieve.lua
-- the sieve of Eratosthenes programmed with coroutines
-- typical usage: lua -e N=500 sieve.lua | column
-- generate all the numbers from 2 to n
function gen (n)
return coroutine.wrap(function ()
for i=2,n do coroutine.yield(i) end
end)
end
-- filter the numbers generated by `g', removing multiples of `p'
function filter (p, g)
return coroutine.wrap(function ()
for n in g do
if n%p ~= 0 then coroutine.yield(n) end
end
end)
end
N=N or 500 -- from command line
x = gen(N) -- generate primes up to N
while 1 do
local n = x() -- pick a number until done
if n == nil then break end
print(n) -- must be a prime number
x = filter(n, x) -- now remove its multiples
end

14
tests/tests.yml Normal file
View File

@ -0,0 +1,14 @@
---
# This first play always runs on the local staging system
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
- container
- atomic
tests:
- Smoke
required_packages:
- lua # Required for smoke test
- which # Required for smoke test