Nmap Development mailing list archives

--script-updatedb causes unhandled exception


From: jah <jah () zadkiel plus com>
Date: Sat, 26 Jul 2008 16:22:06 +0100

Hello,

I crashed nmap trying to update scripts/script.db.
I noticed, whilst stepping through a debug build, that between opening
and closing script.db, nothing was being written to it.  The following
loop was never entered for each script processed:

while (lua_next(L, -2) != 0)
      {
        lua_pushvalue(L, -3); // string.lower
        lua_insert(L, -2); // put below category string
        lua_call(L, 1, 1); // lowered string on stack
        fprintf(scriptdb, "Entry{ category = \"%s\", filename = \"%s\" }\n",
            lua_tostring(L, -1), filebase);
        lua_pop(L, 1);
      }

Hence, nothing to write to the db.

I tried   while (lua_next(L, -3) != 0)   and this seems to fix that
issue and results in a proper script.db.

I've attached a patch, but I'm not sure whether it is the proper fix...


Regards,


jah
--- nse_init.cc.orig    2008-07-26 16:09:37.031250000 +0100
+++ nse_init.cc 2008-07-26 15:40:26.390625000 +0100
@@ -381,7 +381,7 @@
       lua_getglobal(L, "string");
       lua_getfield(L, -1, "lower"); lua_replace(L, -2);
       lua_pushnil(L);
-      while (lua_next(L, -2) != 0)
+      while (lua_next(L, -3) != 0)
       {
         lua_pushvalue(L, -3); // string.lower
         lua_insert(L, -2); // put below category string

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

Current thread: