diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-15 10:38:09 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-15 10:38:09 -0300 |
commit | 38cc7d40a4bcb89314d212fdffd2ca8deebc3cb7 (patch) | |
tree | e641ef35321e0b81cdd1ab577aeaaa1b40858437 | |
parent | bc970005ce2e258e29a5c315ea4e49f76a66586e (diff) | |
download | lua-github-38cc7d40a4bcb89314d212fdffd2ca8deebc3cb7.tar.gz |
Bug: cannot allow the call 'debug.getinfo(0, ">")'
A 'what' argument starting with '>' indicates that there is a function
in the C stack, which won't be there if the first argument is not a
function.
-rw-r--r-- | ldblib.c | 1 | ||||
-rw-r--r-- | testes/db.lua | 1 |
2 files changed, 2 insertions, 0 deletions
@@ -152,6 +152,7 @@ static int db_getinfo (lua_State *L) { lua_State *L1 = getthread(L, &arg); const char *options = luaL_optstring(L, arg+2, "flnSrtu"); checkstack(L, L1, 3); + luaL_argcheck(L, options[0] != '>', arg + 2, "invalid option '>'"); if (lua_isfunction(L, arg + 1)) { /* info about a function? */ options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */ lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ diff --git a/testes/db.lua b/testes/db.lua index ce559ad9..d64952d9 100644 --- a/testes/db.lua +++ b/testes/db.lua @@ -31,6 +31,7 @@ end do assert(not pcall(debug.getinfo, print, "X")) -- invalid option + assert(not pcall(debug.getinfo, 0, ">")) -- invalid option assert(not debug.getinfo(1000)) -- out of range level assert(not debug.getinfo(-1)) -- out of range level local a = debug.getinfo(print) |