1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

set srand when creating the Lua state not when beginning a new scan phase

This commit is contained in:
batrick
2012-01-13 00:16:17 +00:00
parent 541091eed1
commit 6fddf7e4c9

View File

@@ -591,6 +591,13 @@ void open_nse (void)
{
if (L_NSE == NULL)
{
/*
Set the random seed value on behalf of scripts. Since Lua uses the
C rand and srand functions, which have a static seed for the entire
program, we don't want scripts doing this themselves.
*/
srand(get_random_uint());
if ((L_NSE = luaL_newstate()) == NULL)
fatal("%s: failed to open a Lua state!", SCRIPT_ENGINE);
lua_atpanic(L_NSE, panic);
@@ -615,13 +622,6 @@ void script_scan (std::vector<Target *> &targets, stype scantype)
assert(L_NSE != NULL);
lua_settop(L_NSE, 0); /* clear the stack */
/*
Set the random seed value on behalf of scripts. Since Lua uses the C rand
and srand functions, which have a static seed for the entire program, we
don't want scripts doing this themselves.
*/
srand(get_random_uint());
#if 0
/* Lua 5.2 */
lua_pushcfunction(L_NSE, run_main);