Nmap Development mailing list archives

nse exceptions false or nil


From: "Jaime Reza" <turinreza () gmail com>
Date: Wed, 12 Mar 2008 09:34:45 -0800

there was a bug fix for the nse_nmaplib.cc file's
l_exc_finalize that wasn't checked into svn

Index: nse_nmaplib.cc
===================================================================
--- nse_nmaplib.cc      (revision 6128)
+++ nse_nmaplib.cc      (working copy)
@@ -460,13 +460,15 @@
 }

 static int l_exc_finalize(lua_State *l) {
-       if (lua_isnil(l, 1)) {
+       if (!lua_toboolean(l, 1)) {
+               /* false or nil. */
                lua_pushvalue(l, lua_upvalueindex(1));
                lua_call(l, 0, 0);
                lua_settop(l, 2);
                lua_error(l);
                return 0;
-       } else if(lua_toboolean(l, 1)) {
+       } else if(lua_isboolean(l, 1) && lua_toboolean(l, 1)) {
+               /* true. */
                lua_remove(l, 1);
                return lua_gettop(l);
        } else {

The latest code from svn has
static int l_exc_finalize(lua_State *l) {
    if (!lua_toboolean(l, 1)) {
        /* false or nil. */
        lua_pushvalue(l, lua_upvalueindex(1));
        lua_call(l, 0, 0);
        lua_settop(l, 2);
        lua_error(l);
        return 0;
    } else if(lua_isboolean(l, 1) && lua_toboolean(l, 1)) {
        /* true. */
        lua_remove(l, 1);
        return lua_gettop(l);
    } else {
        fatal("%s: In: %s:%i Trying to finalize a non conforming function.
Are you sure you return true on success followed by the remaining return
values and nil on failure followed by an error string?",
            SCRIPT_ENGINE, __FILE__, __LINE__);

        return 0;
    }
}

Which one is correct? the one in svn (latest sink is giving me troubles)
thanks
Turinreza

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


Current thread: