From e807b9245982b308e018645b7a5712d0c6acdd67 Mon Sep 17 00:00:00 2001 From: batrick Date: Fri, 28 Aug 2009 21:01:29 +0000 Subject: [PATCH] [NSE] Scripts are able to access hosts from a previous host group which were scanned and freed. This is unintended and may cause a segfault. We fix this by replacing the current_hosts table with a new empty table when scanning a new host group. See [1] for more information. [1] http://seclists.org/nmap-dev/2009/q3/0782.html --- nse_main.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nse_main.cc b/nse_main.cc index 4571dc608..ab9006ff7 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -433,6 +433,12 @@ static int run_main (lua_State *L) lua_touserdata(L, 1); lua_settop(L, 0); + + /* New host group */ + luaL_unref(L, LUA_REGISTRYINDEX, current_hosts); + lua_newtable(L); + current_hosts = luaL_ref(L, LUA_REGISTRYINDEX); + lua_getfield(L, LUA_REGISTRYINDEX, NSE_TRACEBACK); /* index 1 */ lua_getfield(L, LUA_REGISTRYINDEX, NSE_MAIN); /* index 2 */