diff --git a/CHANGELOG b/CHANGELOG index be7c6d6a1..5f740f2fc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,11 @@ o Reformat Nmap COPYING file (e.g. remove C comment markers, reduce when presented by the Windows executable (NSIS) installer. Thanks to Jah for the patch (which was modified slightly by Fyodor). +o Changed the NSE function nmap.set_port_state() so that it checks to + see if the requested port is already in the requested state. This + prevents "Duplicate port" messages during the script scan and the + inaccurate "script-set" state reason. [Kris] + o Updated ripeQuery.nse to not print extraneous whitespace. [Kris] Nmap 4.60 diff --git a/nse_nmaplib.cc b/nse_nmaplib.cc index 0bd3f8cb7..a9543be6a 100644 --- a/nse_nmaplib.cc +++ b/nse_nmaplib.cc @@ -371,12 +371,16 @@ static int l_set_port_state(lua_State* l, Target* target, Port* port) { case 'o': if (strcmp(state, "open")) luaL_argerror (l, 4, "Invalid port state."); + if (port->state == PORT_OPEN) + goto noset; plist->addPort(port->portno, port->proto, NULL, PORT_OPEN); port->state = PORT_OPEN; break; case 'c': if (strcmp(state, "closed")) luaL_argerror (l, 4, "Invalid port state."); + if (port->state == PORT_CLOSED) + goto noset; plist->addPort(port->portno, port->proto, NULL, PORT_CLOSED); port->state = PORT_CLOSED; break; @@ -386,6 +390,7 @@ static int l_set_port_state(lua_State* l, Target* target, Port* port) { port->reason.reason_id = ER_SCRIPT; +noset: free(state); return 0; }