From d92a2ca2a43c68854011e2f84ce0a75802d854be Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Mon, 20 Jan 2014 15:34:25 +0100 Subject: Turn potential malicious-crafted code crashes into normal Lua errors * bump version to 3.8.1 * new function lane:get_debug_threadname() * Fix invalid memory accesses when fetching the name of a joined lane with lanes:threads() (because its lua_State is closed) * use luaL_newmetatable() to create the metatable for lane objects * prevent malicious code from crashing by calling lane methods without passing the lane as first argument (raise an error instead) * set_debug_threadname() is no longer registered in the function lookup databases because it holds a C pointer as upvalue and it might crash if used maliciously --- tests/basic.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/basic.lua b/tests/basic.lua index 1f4eb1e..5b0d8a7 100644 --- a/tests/basic.lua +++ b/tests/basic.lua @@ -413,6 +413,8 @@ PRINT( "\n\n", "---=== :join test ===---", "\n\n") local S= lanes_gen( "table", function(arg) + set_debug_threadname "join test lane" + set_finalizer( function() end) aux= {} for i, v in ipairs(arg) do table.insert (aux, 1, v) @@ -422,11 +424,14 @@ local S= lanes_gen( "table", end ) h= S { 12, 13, 14 } -- execution starts, h[1..3] will get the return values - +-- wait a bit so that the lane hasa chance to set its debug name +linda:receive(0.5, "gloupti") +print( "joining with '" .. h:get_debug_threadname() .. "'") local a,b,c,d= h:join() if h.status == "error" then - print( "h error: " , a, b, c, d) + print( h:get_debug_threadname(), "error: " , a, b, c, d) else + print( h:get_debug_threadname(), a,b,c,d) assert(a==14) assert(b==13) assert(c==12) -- cgit v1.2.3-55-g6feb