From 68a9147b69f9396bcc40e8eea8b7cdedc7febcd6 Mon Sep 17 00:00:00 2001 From: batrick Date: Sat, 29 Aug 2009 20:21:58 +0000 Subject: [PATCH] [NSE] Fixed some bugs in the vhosts patch applied in 15342: o Stack indices for the 'ip' and 'targetname' strings were wrong. o Moved the lightuserdatum check right before done so a nil can't slip through. --- nse_nmaplib.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index f6b365dff..b276e0ace 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -334,20 +334,18 @@ Target *get_target (lua_State *L, int index) lua_getfield(L, index, "ip"); if (!(lua_isstring(L, -2) || lua_isstring(L, -1))) luaL_error(L, "host table does not have a 'ip' or 'targetname' field"); - if (lua_isstring(L, -3)) /* targetname */ + if (lua_isstring(L, -2)) /* targetname */ { - nse_gettarget(L, -3); /* use targetname */ + nse_gettarget(L, -2); /* use targetname */ if (lua_islightuserdata(L, -1)) goto done; else lua_pop(L, 1); } - if (lua_isstring(L, -2)) /* ip */ - { - nse_gettarget(L, -2); /* use ip */ - if (!lua_islightuserdata(L, -1)) - luaL_argerror(L, 1, "host is not being processed right now"); - } + if (lua_isstring(L, -1)) /* ip */ + nse_gettarget(L, -1); /* use ip */ + if (!lua_islightuserdata(L, -1)) + luaL_argerror(L, 1, "host is not being processed right now"); done: target = (Target *) lua_touserdata(L, -1); lua_settop(L, top); /* reset stack */