Nmap Development mailing list archives

Re: XML structured script output (storing results per script instance)


From: David Fifield <david () bamsoftware com>
Date: Tue, 31 Jul 2012 18:07:40 -0700

Daniel's structured output branch stores the output of a script as a Lua
object in the Lua registry, in a table keyed by "NSE_SCRIPT_RESULT"] and
subkeyed by the pointer to the script instance. Here's an excerpt from
ScriptResult::set_output:

  key = lua_topointer(L, pos+1);
  lua_getfield(lstate, LUA_REGISTRYINDEX, NSE_SCRIPT_RESULT); /* -3 */
  lua_pushfstring(lstate, "%p", key); /* -2 */
  lua_pushvalue(lstate, pos); /* -1 */
  lua_settable(lstate, -3); /* _R[NSE_SCRIPT_RESULT][key] = return_value */

Lua experts: is this the usual way to accomplish this? Is it safe to
rely on addresses in this way?

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: