]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Randomize Lua PRNG at startup
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Aug 2017 20:59:44 +0000 (21:59 +0100)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 28 Aug 2017 11:07:18 +0000 (13:07 +0200)
src/lua/lua_common.c

index 2af506f13c727b166643ca560fe663311fe66622..ebdd472911e86dbc2b440faa861d93e0fc8aa767 100644 (file)
@@ -330,6 +330,14 @@ rspamd_lua_init ()
        lua_newtable (L);
        lua_setglobal (L, "rspamd_plugins");
 
+       /* Set PRNG */
+       lua_getglobal (L, "math");
+       lua_pushstring (L, "randomseed");
+       lua_gettable (L, -2);
+       lua_pushnumber (L, ottery_rand_uint64 ());
+       lua_pcall (L, 1, 0, 0);
+       lua_pop (L, 1); /* math table */
+
        return L;
 }