From e515cb46d8c3c86b35a918cbb8e8f7860bf31d94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christophe=20Thi=C3=A9ry?= Date: Wed, 9 Nov 2011 19:02:00 +0100 Subject: [PATCH] When a C function is called by Lua, get the args with positive indices A negative index is unsafe since the caller may provide more arguments than needed. --- src/bindings/lua/simgrid_lua.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bindings/lua/simgrid_lua.c b/src/bindings/lua/simgrid_lua.c index 76a482e76e..fc62dcb78a 100644 --- a/src/bindings/lua/simgrid_lua.c +++ b/src/bindings/lua/simgrid_lua.c @@ -300,7 +300,7 @@ static int l_host_get_by_name(lua_State * L) static int l_host_get_name(lua_State * L) { - m_host_t ht = sglua_checkhost(L, -1); + m_host_t ht = sglua_checkhost(L, 1); lua_pushstring(L, MSG_host_get_name(ht)); return 1; } @@ -345,22 +345,22 @@ static int l_host_self(lua_State * L) static int l_host_get_property_value(lua_State * L) { - m_host_t ht = sglua_checkhost(L, -2); - const char *prop = luaL_checkstring(L, -1); + m_host_t ht = sglua_checkhost(L, 1); + const char *prop = luaL_checkstring(L, 2); lua_pushstring(L,MSG_host_get_property_value(ht,prop)); return 1; } static int l_host_sleep(lua_State *L) { - int time = luaL_checknumber(L, -1); + int time = luaL_checknumber(L, 1); MSG_process_sleep(time); return 1; } static int l_host_destroy(lua_State *L) { - m_host_t ht = sglua_checkhost(L, -1); + m_host_t ht = sglua_checkhost(L, 1); __MSG_host_destroy(ht); return 1; } -- 2.20.1