diff options
author | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-01-20 15:34:25 +0100 |
---|---|---|
committer | Benoit Germain <bnt period germain arrobase gmail period com> | 2014-01-20 15:34:25 +0100 |
commit | d92a2ca2a43c68854011e2f84ce0a75802d854be (patch) | |
tree | e9bbd0b69f67609cdff23664d9a322e532c17a10 /tests | |
parent | cf9b09ff352611fb8cee3679127f3655cbe73ae7 (diff) | |
download | lanes-d92a2ca2a43c68854011e2f84ce0a75802d854be.tar.gz lanes-d92a2ca2a43c68854011e2f84ce0a75802d854be.tar.bz2 lanes-d92a2ca2a43c68854011e2f84ce0a75802d854be.zip |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basic.lua | 9 |
1 files changed, 7 insertions, 2 deletions
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") | |||
413 | 413 | ||
414 | local S= lanes_gen( "table", | 414 | local S= lanes_gen( "table", |
415 | function(arg) | 415 | function(arg) |
416 | set_debug_threadname "join test lane" | ||
417 | set_finalizer( function() end) | ||
416 | aux= {} | 418 | aux= {} |
417 | for i, v in ipairs(arg) do | 419 | for i, v in ipairs(arg) do |
418 | table.insert (aux, 1, v) | 420 | table.insert (aux, 1, v) |
@@ -422,11 +424,14 @@ local S= lanes_gen( "table", | |||
422 | end ) | 424 | end ) |
423 | 425 | ||
424 | h= S { 12, 13, 14 } -- execution starts, h[1..3] will get the return values | 426 | h= S { 12, 13, 14 } -- execution starts, h[1..3] will get the return values |
425 | 427 | -- wait a bit so that the lane hasa chance to set its debug name | |
428 | linda:receive(0.5, "gloupti") | ||
429 | print( "joining with '" .. h:get_debug_threadname() .. "'") | ||
426 | local a,b,c,d= h:join() | 430 | local a,b,c,d= h:join() |
427 | if h.status == "error" then | 431 | if h.status == "error" then |
428 | print( "h error: " , a, b, c, d) | 432 | print( h:get_debug_threadname(), "error: " , a, b, c, d) |
429 | else | 433 | else |
434 | print( h:get_debug_threadname(), a,b,c,d) | ||
430 | assert(a==14) | 435 | assert(a==14) |
431 | assert(b==13) | 436 | assert(b==13) |
432 | assert(c==12) | 437 | assert(c==12) |