Accepting request 909224 from home:gmbr3:Lua

- Add upstream-bugs.patch and upstream-bugs-test.patch to fix
  bugs 4,5,6 for build and tests respectively.

OBS-URL: https://build.opensuse.org/request/show/909224
OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=37
This commit is contained in:
Callum Farmer 2021-07-29 16:34:25 +00:00 committed by Git OBS Bridge
parent 8bc2aae476
commit 345f635bed
4 changed files with 148 additions and 1 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Jul 29 16:31:23 UTC 2021 - Callum Farmer <gmbr3@opensuse.org>
- Add upstream-bugs.patch and upstream-bugs-test.patch to fix
bugs 4,5,6 for build and tests respectively.
-------------------------------------------------------------------
Sat May 22 12:58:16 UTC 2021 - Callum Farmer <gmbr3@opensuse.org>

View File

@ -1,7 +1,7 @@
#
# spec file for package lua54
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed

View File

@ -102,3 +102,73 @@ index 6aad5d253..6151f64d0 100644
do
-- yielding inside closing metamethods after an error
diff --git a/testes/locals.lua b/testes/locals.lua
index 6151f64d0..62a88df57 100644
--- a/locals.lua
+++ b/locals.lua
@@ -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 --git a/testes/bitwise.lua b/testes/bitwise.lua
index 59781f5df..9509f7f04 100644
--- a/bitwise.lua
+++ b/bitwise.lua
@@ -45,6 +45,11 @@ assert(-1 >> numbits == 0 and
-1 << numbits == 0 and
-1 << -numbits == 0)
+assert(1 >> math.mininteger == 0)
+assert(1 >> math.maxinteger == 0)
+assert(1 << math.mininteger == 0)
+assert(1 << math.maxinteger == 0)
+
assert((2^30 - 1) << 2^30 == 0)
assert((2^30 - 1) >> 2^30 == 0)
diff --git a/testes/errors.lua b/testes/errors.lua
index 825f37c29..a7dc479a2 100644
--- a/errors.lua
+++ b/errors.lua
@@ -228,6 +228,22 @@ do -- named objects (field '__name')
checkmessage("return {} < XX", "table with My Type")
checkmessage("return XX < io.stdin", "My Type with FILE*")
_G.XX = nil
+
+ if T then -- extra tests for 'luaL_tolstring'
+ -- bug in 5.4.3; 'luaL_tolstring' with negative indices
+ local x = setmetatable({}, {__name="TABLE"})
+ assert(T.testC("Ltolstring -1; return 1", x) == tostring(x))
+
+ local a, b = T.testC("pushint 10; Ltolstring -2; return 2", x)
+ assert(a == 10 and b == tostring(x))
+
+ setmetatable(x, {__tostring=function (o)
+ assert(o == x)
+ return "ABC"
+ end})
+ a, b, c = T.testC("pushint 10; Ltolstring -2; return 3", x)
+ assert(a == x and b == 10 and c == "ABC")
+ end
end
-- global functions
diff --git a/ltests.c b/ltests.c
index a50f78304..97834e380 100644
--- a/ltests/ltests.c
+++ b/ltests/ltests.c
@@ -1743,6 +1743,9 @@ static struct X { int x; } x;
(void)s1; /* to avoid warnings */
lua_longassert((s == NULL && s1 == NULL) || strcmp(s, s1) == 0);
}
+ else if EQ("Ltolstring") {
+ luaL_tolstring(L1, getindex, NULL);
+ }
else if EQ("type") {
lua_pushstring(L1, luaL_typename(L1, getnum));
}

View File

@ -147,3 +147,74 @@ index 16e01d683..e4b1903e7 100644
if (L->top < ci->top)
L->top = ci->top;
luaF_close(L, base, CLOSEKTOP, 1);
From 6a0dace25a4b5b77f0fa6911de2ba26ef0fdff2c Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Sun, 20 Jun 2021 15:36:36 -0300
Subject: [PATCH] Bug: 'local function' can assign to '<const>' variables
---
lparser.c | 1 +
testes/locals.lua | 2 ++
2 files changed, 3 insertions(+)
diff --git a/lparser.c b/lparser.c
index df9473c27..3abe3d751 100644
--- a/src/lparser.c
+++ b/src/lparser.c
@@ -1785,6 +1785,7 @@ static void funcstat (LexState *ls, int line) {
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 */
}
From 62fb93442753cbfb828335cd172e71471dffd536 Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 22 Jul 2021 13:44:53 -0300
Subject: [PATCH] Bug: Negation in 'luaV_shiftr' may overflow
Negation of an unchecked lua_Integer overflows with mininteger.
---
lvm.c | 2 +-
testes/bitwise.lua | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/lvm.c b/lvm.c
index ec83f4159..c84a665f5 100644
--- a/src/lvm.c
+++ b/src/lvm.c
@@ -766,7 +766,7 @@ lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) {
/*
** 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? */
From 439e45a2f69549b674d6a6e2023e8debfa00a2b8 Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 22 Jul 2021 13:48:43 -0300
Subject: [PATCH] Bug: luaL_tolstring may get confused with negative index
When object has a '__name' metafield, 'luaL_tolstring' used the
received index after pushing a string on the stack.
---
lauxlib.c | 1 +
ltests.c | 3 +++
testes/errors.lua | 16 ++++++++++++++++
3 files changed, 20 insertions(+)
diff --git a/lauxlib.c b/lauxlib.c
index 94835ef93..8ed1da112 100644
--- a/src/lauxlib.c
+++ b/src/lauxlib.c
@@ -881,6 +881,7 @@ LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) {
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");