mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 06:01:28 +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:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user