From dab741f30fea8345d00039ac43e2dfa204a613a8 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 15 Jul 2009 02:54:03 +0000 Subject: [PATCH] Make nse_selectedbyname return false if the "NSE_SELECTED_BY_NAME" key is not in the registry. That function is called indirectly by nmap.verbosity, which may be called before _R["NSE_SELECTED_BY_NAME"] has been given a value. I was getting this error with any script scan: NSE: failed to initialize the script engine: attempt to call a nil value stack traceback: [C]: in function 'verbosity' ./nse_main.lua:136: in function 'print_verbose' ./nse_main.lua:680: in main chunk [C]: ? QUITTING! --- nse_main.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nse_main.cc b/nse_main.cc index 2a5ae05fe..26be4393f 100644 --- a/nse_main.cc +++ b/nse_main.cc @@ -533,7 +533,12 @@ void nse_base (lua_State *L) void nse_selectedbyname (lua_State *L) { lua_getfield(L, LUA_REGISTRYINDEX, NSE_SELECTED_BY_NAME); - lua_call(L, 0, 1); /* returns boolean, whether script was selected by name */ + if (lua_isnil(L, -1)) { + lua_pushboolean(L, 0); + lua_replace(L, -2); + } else { + lua_call(L, 0, 1); /* returns boolean, whether script was selected by name */ + } } static lua_State *L_NSE = NULL;