From 9b9aceac929a7e7e072002983ad4645dc2f3bcc1 Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 27 Mar 2012 21:55:32 +0000 Subject: [PATCH] Fix to allow cpe port table entry to be nil when calling set_port_version --- nse_nmaplib.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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,