Nmap Development mailing list archives

RE: NSE's garbage collection and exception handling


From: "Matthew Boyle" <matt_boyle32 () hotmail com>
Date: Sat, 08 Sep 2007 18:00:35 +0000

From: "Kris Katterjohn" <katterjohn () gmail com>
To: "Nmap Dev" <nmap-dev () insecure org>
Subject: NSE's garbage collection and exception handling
Date: Sat, 8 Sep 2007 08:52:30 -0500

Hey everyone!

I've been reading over the NSE guide[1] recently and got to thinking about
something for which I couldn't find an answer: does the garbage collection
Stoiko added (closing sockets forgotten when exiting a script) still happen
when NSE exceptions occur[2]?

All of the examples that I've seen show the "catch" function (or whatever 
it
happens to be called) closing the socket.  What happens if we don't have
it?  Does the socket still get closed?  Does the script just exit normally
after an NSE exception, and thus the sockets get closed as it would if no
exception occurred at all?

as far as i can tell, when the exception occurs, the script is terminated 
once your catch-function returns (NSE pushes the error string onto the 
stack, then calls lua_error() 
[http://www.lua.org/manual/5.1/manual.html#lua_error].  in which case, it 
shouldn't be necessary to close the socket explicitly; the garbage collector 
should take care of that.

it would also seem that, so long as you don't need to do anything special, 
you don't need to define a catch-function.  if you just put

local try = nmap.new_try(nil);

in your script, NSE will call l_exc_do_nothing() instead.  which, uh, does 
nothing before terminating the script :-)

though some of the error messages could perhaps be a bit more explicit.  
'SCRIPT ENGINE: EOF' isn't perhaps the most descriptive ;-)

--matt

_________________________________________________________________
Got a favourite clothes shop, bar or restaurant? Share your local knowledge  
http://www.backofmyhand.com


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


Current thread: