1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-10 17:59:04 +00:00

[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.
This commit is contained in:
batrick
2009-08-29 20:21:58 +00:00
parent 46d95b5913
commit 68a9147b69

View File

@@ -334,20 +334,18 @@ Target *get_target (lua_State *L, int index)
lua_getfield(L, index, "ip"); lua_getfield(L, index, "ip");
if (!(lua_isstring(L, -2) || lua_isstring(L, -1))) if (!(lua_isstring(L, -2) || lua_isstring(L, -1)))
luaL_error(L, "host table does not have a 'ip' or 'targetname' field"); 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)) if (lua_islightuserdata(L, -1))
goto done; goto done;
else else
lua_pop(L, 1); lua_pop(L, 1);
} }
if (lua_isstring(L, -2)) /* ip */ if (lua_isstring(L, -1)) /* ip */
{ nse_gettarget(L, -1); /* use ip */
nse_gettarget(L, -2); /* use ip */ if (!lua_islightuserdata(L, -1))
if (!lua_islightuserdata(L, -1)) luaL_argerror(L, 1, "host is not being processed right now");
luaL_argerror(L, 1, "host is not being processed right now");
}
done: done:
target = (Target *) lua_touserdata(L, -1); target = (Target *) lua_touserdata(L, -1);
lua_settop(L, top); /* reset stack */ lua_settop(L, top); /* reset stack */