diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index 766cf8a82..f5a624f38 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -594,13 +594,15 @@ static int l_set_port_version (lua_State *L) luaL_argerror(L, 2, "invalid value for port.version.service_tunnel"); lua_getfield(L, 4, "cpe"); - if (!lua_istable(L, -1)) + if (lua_isnil(L, -1)) + ; + else if(lua_istable(L, -1)) + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { + cpe.push_back(lua_tostring(L, -1)); + } + else luaL_error(L, "port.version 'cpe' field must be a table"); - for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { - cpe.push_back(lua_tostring(L, -1)); - } - if (o.servicescan) target->ports.setServiceProbeResults(p->portno, p->proto, probestate, name, tunnel, product,