From 9b4f39ab14fb2e55345c3d23537d129dac23b091 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 17 Aug 2023 15:59:28 -0300 Subject: More disciplined use of 'getstr' and 'tsslen' We may want to add other string variants in the future; this change documents better where the code may need to handle those variants. --- lundump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lundump.c') diff --git a/lundump.c b/lundump.c index 02aed64f..f1852c35 100644 --- a/lundump.c +++ b/lundump.c @@ -122,7 +122,7 @@ static TString *loadStringN (LoadState *S, Proto *p) { ts = luaS_createlngstrobj(L, size); /* create string */ setsvalue2s(L, L->top.p, ts); /* anchor it ('loadVector' can GC) */ luaD_inctop(L); - loadVector(S, getstr(ts), size); /* load directly in final place */ + loadVector(S, getlngstr(ts), size); /* load directly in final place */ L->top.p--; /* pop string */ } luaC_objbarrier(L, p, ts); -- cgit v1.2.3-55-g6feb From 6baee9ef9d5657ab582c8a4b9f885ec58ed502d0 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 8 Sep 2023 16:19:21 -0300 Subject: Removed test for "corrupted binary dump" Test is too non portable. (For instance, it does not work for different number types.) --- lundump.c | 2 +- testes/calls.lua | 14 -------------- 2 files changed, 1 insertion(+), 15 deletions(-) (limited to 'lundump.c') diff --git a/lundump.c b/lundump.c index f1852c35..e8d92a85 100644 --- a/lundump.c +++ b/lundump.c @@ -81,7 +81,7 @@ static size_t loadUnsigned (LoadState *S, size_t limit) { static size_t loadSize (LoadState *S) { - return loadUnsigned(S, ~(size_t)0); + return loadUnsigned(S, MAX_SIZET); } diff --git a/testes/calls.lua b/testes/calls.lua index 664be1b4..a1938584 100644 --- a/testes/calls.lua +++ b/testes/calls.lua @@ -342,20 +342,6 @@ do -- another bug (in 5.4.0) end -if not _port then -- another bug (since 5.2) - -- corrupted binary dump: list of upvalue names is larger than number - -- of upvalues, overflowing the array of upvalues. - local code = - "\x1b\x4c\x75\x61\x54\x00\x19\x93\x0d\x0a\x1a\x0a\x04\x08\x08\x78\x56\z - \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x28\x77\x40\x00\x86\x40\z - \x74\x65\x6d\x70\x81\x81\x01\x00\x02\x82\x48\x00\x02\x00\xc7\x00\x01\z - \x00\x80\x80\x80\x82\x00\x00\x80\x81\x82\x78\x80\x82\x81\x86\x40\x74\z - \x65\x6d\x70" - - assert(load(code)) -- segfaults in previous versions -end - - x = string.dump(load("x = 1; return x")) a = assert(load(read1(x), nil, "b")) assert(a() == 1 and _G.x == 1) -- cgit v1.2.3-55-g6feb