Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lua54 for openSUSE:Factory checked in at 2022-12-20 20:19:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lua54 (Old) and /work/SRC/openSUSE:Factory/.lua54.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lua54" Tue Dec 20 20:19:40 2022 rev:21 rq:1043640 version:5.4.4 Changes: -------- --- /work/SRC/openSUSE:Factory/lua54/lua54.changes 2022-09-01 22:09:25.875958683 +0200 +++ /work/SRC/openSUSE:Factory/.lua54.new.1835/lua54.changes 2022-12-20 20:19:41.813618401 +0100 @@ -1,0 +2,7 @@ +Sun Dec 18 17:55:21 UTC 2022 - Callum Farmer <gm...@opensuse.org> + +- Added more numbered patches from upstream: + * luabugs8.patch + * luabugs9.patch + +------------------------------------------------------------------- New: ---- luabugs8.patch luabugs9.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lua54.spec ++++++ --- /var/tmp/diff_new_pack.SqFinT/_old 2022-12-20 20:19:43.269626382 +0100 +++ /var/tmp/diff_new_pack.SqFinT/_new 2022-12-20 20:19:43.277626426 +0100 @@ -51,6 +51,8 @@ Patch11: luabugs5.patch Patch12: luabugs6.patch Patch13: luabugs7.patch +Patch14: luabugs8.patch +Patch15: luabugs9.patch # %if "%{flavor}" == "test" BuildRequires: lua54 ++++++ luabugs8.patch ++++++ >From a1089b415a3f5c753aa1b40758ffdaf28d5701b0 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <robe...@inf.puc-rio.br> Date: Fri, 23 Sep 2022 10:41:16 -0300 Subject: [PATCH] Bug: 'utf8.codes' accepts spurious continuation bytes --- lutf8lib.c | 27 ++++++++++++++++----------- testes/utf8.lua | 12 +++++++++++- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lutf8lib.c b/lutf8lib.c index e7bf098f6..3a5b9bc38 100644 --- a/src/lutf8lib.c +++ b/src/lutf8lib.c @@ -25,6 +25,9 @@ #define MAXUTF 0x7FFFFFFFu + +#define MSGInvalid "invalid UTF-8 code" + /* ** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits. */ @@ -35,7 +38,8 @@ typedef unsigned long utfint; #endif -#define iscont(p) ((*(p) & 0xC0) == 0x80) +#define iscont(c) (((c) & 0xC0) == 0x80) +#define iscontp(p) iscont(*(p)) /* from strlib */ @@ -65,7 +69,7 @@ static const char *utf8_decode (const char *s, utfint *val, int strict) { int count = 0; /* to count number of continuation bytes */ for (; c & 0x40; c <<= 1) { /* while it needs continuation bytes... */ unsigned int cc = (unsigned char)s[++count]; /* read next byte */ - if ((cc & 0xC0) != 0x80) /* not a continuation byte? */ + if (!iscont(cc)) /* not a continuation byte? */ return NULL; /* invalid byte sequence */ res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */ } @@ -140,7 +144,7 @@ static int codepoint (lua_State *L) { utfint code; s = utf8_decode(s, &code, !lax); if (s == NULL) - return luaL_error(L, "invalid UTF-8 code"); + return luaL_error(L, MSGInvalid); lua_pushinteger(L, code); n++; } @@ -190,16 +194,16 @@ static int byteoffset (lua_State *L) { "position out of bounds"); if (n == 0) { /* find beginning of current byte sequence */ - while (posi > 0 && iscont(s + posi)) posi--; + while (posi > 0 && iscontp(s + posi)) posi--; } else { - if (iscont(s + posi)) + if (iscontp(s + posi)) return luaL_error(L, "initial position is a continuation byte"); if (n < 0) { while (n < 0 && posi > 0) { /* move back */ do { /* find beginning of previous character */ posi--; - } while (posi > 0 && iscont(s + posi)); + } while (posi > 0 && iscontp(s + posi)); n++; } } @@ -208,7 +212,7 @@ static int byteoffset (lua_State *L) { while (n > 0 && posi < (lua_Integer)len) { do { /* find beginning of next character */ posi++; - } while (iscont(s + posi)); /* (cannot pass final '\0') */ + } while (iscontp(s + posi)); /* (cannot pass final '\0') */ n--; } } @@ -226,15 +230,15 @@ static int iter_aux (lua_State *L, int strict) { const char *s = luaL_checklstring(L, 1, &len); lua_Unsigned n = (lua_Unsigned)lua_tointeger(L, 2); if (n < len) { - while (iscont(s + n)) n++; /* skip continuation bytes */ + while (iscontp(s + n)) n++; /* go to next character */ } if (n >= len) /* (also handles original 'n' being negative) */ return 0; /* no more codepoints */ else { utfint code; const char *next = utf8_decode(s + n, &code, strict); - if (next == NULL) - return luaL_error(L, "invalid UTF-8 code"); + if (next == NULL || iscontp(next)) + return luaL_error(L, MSGInvalid); lua_pushinteger(L, n + 1); lua_pushinteger(L, code); return 2; @@ -253,7 +257,8 @@ static int iter_auxlax (lua_State *L) { static int iter_codes (lua_State *L) { int lax = lua_toboolean(L, 2); - luaL_checkstring(L, 1); + const char *s = luaL_checkstring(L, 1); + luaL_argcheck(L, !iscontp(s), 1, MSGInvalid); lua_pushcfunction(L, lax ? iter_auxlax : iter_auxstrict); lua_pushvalue(L, 1); lua_pushinteger(L, 0); diff --git a/testes/utf8.lua b/testes/utf8.lua index 461e223c7..7472cfd05 100644 --- a/testes/utf8.lua +++ b/testes/utf8.lua @@ -97,9 +97,15 @@ do -- error indication in utf8.len assert(not a and b == p) end check("abc\xE3def", 4) - check("æ±å\x80", #("æ±å") + 1) check("\xF4\x9F\xBF", 1) check("\xF4\x9F\xBF\xBF", 1) + -- spurious continuation bytes + check("æ±å\x80", #("æ±å") + 1) + check("\x80hello", 1) + check("hel\x80lo", 4) + check("æ±å\xBF", #("æ±å") + 1) + check("\xBFhello", 1) + check("hel\xBFlo", 4) end -- errors in utf8.codes @@ -112,12 +118,16 @@ do end errorcodes("ab\xff") errorcodes("\u{110000}") + errorcodes("in\x80valid") + errorcodes("\xbfinvalid") + errorcodes("αλÏ\xBFα") -- calling interation function with invalid arguments local f = utf8.codes("") assert(f("", 2) == nil) assert(f("", -1) == nil) assert(f("", math.mininteger) == nil) + end -- error in initial position for offset ++++++ luabugs9.patch ++++++ >From 1e64c1391f9a14115b5cc82066dbf545ae73ee27 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy <robe...@inf.puc-rio.br> Date: Tue, 25 Oct 2022 16:44:06 -0300 Subject: [PATCH] Bug: stack overflow with nesting of coroutine.close --- lcorolib.c | 4 ++-- lstate.c | 3 ++- ltests.c | 2 +- lua.h | 2 +- manual/manual.of | 7 ++++++- testes/cstack.lua | 26 ++++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lcorolib.c b/lcorolib.c index 785a1e81a..40b880b14 100644 --- a/src/lcorolib.c +++ b/src/lcorolib.c @@ -76,7 +76,7 @@ static int luaB_auxwrap (lua_State *L) { if (l_unlikely(r < 0)) { /* error? */ int stat = lua_status(co); if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ - stat = lua_resetthread(co); /* close its tbc variables */ + stat = lua_resetthread(co, L); /* close its tbc variables */ lua_assert(stat != LUA_OK); lua_xmove(co, L, 1); /* move error message to the caller */ } @@ -172,7 +172,7 @@ static int luaB_close (lua_State *L) { int status = auxstatus(L, co); switch (status) { case COS_DEAD: case COS_YIELD: { - status = lua_resetthread(co); + status = lua_resetthread(co, L); if (status == LUA_OK) { lua_pushboolean(L, 1); return 1; diff --git a/lstate.c b/lstate.c index 1ffe1a0f7..4b5c10008 100644 --- a/src/lstate.c +++ b/src/lstate.c @@ -343,9 +343,10 @@ int luaE_resetthread (lua_State *L, int status) { } -LUA_API int lua_resetthread (lua_State *L) { +LUA_API int lua_resetthread (lua_State *L, lua_State *from) { int status; lua_lock(L); + L->nCcalls = (from) ? getCcalls(from) : 0; status = luaE_resetthread(L, L->status); lua_unlock(L); return status; diff --git a/lua.h b/lua.h index 219784cc0..bfba4d1e1 100644 --- a/src/lua.h +++ b/src/lua.h @@ -153,7 +153,7 @@ extern const char lua_ident[]; LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); LUA_API void (lua_close) (lua_State *L); LUA_API lua_State *(lua_newthread) (lua_State *L); -LUA_API int (lua_resetthread) (lua_State *L); +LUA_API int (lua_resetthread) (lua_State *L, lua_State *from); LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); diff --git a/testes/cstack.lua b/testes/cstack.lua index ca76c8729..97afe9fd0 100644 --- a/testes/cstack.lua +++ b/testes/cstack.lua @@ -84,6 +84,32 @@ do -- bug in 5.4.0 end +do -- bug since 5.4.0 + local count = 0 + print("chain of 'coroutine.close'") + -- create N coroutines forming a list so that each one, when closed, + -- closes the previous one. (With a large enough N, previous Lua + -- versions crash in this test.) + local coro = false + for i = 1, 1000 do + local previous = coro + coro = coroutine.create(function() + local cc <close> = setmetatable({}, {__close=function() + count = count + 1 + if previous then + assert(coroutine.close(previous)) + end + end}) + coroutine.yield() -- leaves 'cc' pending to be closed + end) + assert(coroutine.resume(coro)) -- start it and run until it yields + end + local st, msg = coroutine.close(coro) + assert(not st and string.find(msg, "C stack overflow")) + print("final count: ", count) +end + + do print("nesting of resuming yielded coroutines") local count = 0