Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 0f6de2d2 authored by rswindell's avatar rswindell

DLL-exporting sbbs_random() and (new function) sbbs_srand() to solve the

problem of the JS global function random() not being seeded by non-sbbs.dll's
(e.g. websrvr.dll) - causing predictable random numbers to be returned.
parent c299f7f6
......@@ -4569,8 +4569,7 @@ void DLLCALL ftp_server(void* arg)
lprintf(LOG_INFO,"Compiled %s %s with %s", __DATE__, __TIME__, compiler);
srand(time(NULL)); /* Seed random number generator */
sbbs_random(10); /* Throw away first number */
sbbs_srand(); /* Seed random number generator */
if(!winsock_startup()) {
cleanup(1,__LINE__);
......
......@@ -4024,7 +4024,7 @@ void DLLCALL mail_server(void* arg)
lprintf(LOG_INFO,"SMBLIB %s (format %x.%02x)",smb_lib_ver(),smb_ver()>>8,smb_ver()&0xff);
srand(time(NULL));
sbbs_srand();
if(!winsock_startup()) {
cleanup(1);
......
......@@ -263,6 +263,17 @@ static BOOL winsock_startup(void)
#endif
DLLEXPORT void DLLCALL sbbs_srand()
{
srand(msclock());
sbbs_random(10); /* Throw away first number */
}
DLLEXPORT int DLLCALL sbbs_random(int n)
{
return(xp_random(n));
}
#ifdef JAVASCRIPT
static js_server_props_t js_server_props;
......@@ -1546,8 +1557,7 @@ void event_thread(void* arg)
sbbs->event_thread_running = true;
srand(time(NULL)); /* Seed random number generator */
sbbs_random(10); /* Throw away first number */
sbbs_srand(); /* Seed random number generator */
thread_up(TRUE /* setuid */);
......@@ -3263,8 +3273,7 @@ void node_thread(void* arg)
lprintf(LOG_DEBUG,"Node %d thread started",sbbs->cfg.node_num);
#endif
srand(time(NULL)); /* Seed random number generator */
sbbs_random(10); /* Throw away first number */
sbbs_srand(); /* Seed random number generator */
#ifdef JAVASCRIPT
if(!(startup->options&BBS_OPT_NO_JAVASCRIPT)) {
......
......@@ -778,6 +778,10 @@ public:
extern "C" {
#endif
/* main.cpp */
DLLEXPORT int DLLCALL sbbs_random(int);
DLLEXPORT void DLLCALL sbbs_srand(void);
/* getstats.c */
DLLEXPORT BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats);
DLLEXPORT ulong DLLCALL getposts(scfg_t* cfg, uint subnum);
......
......@@ -831,7 +831,6 @@ enum { /* Values of mode for userlist function */
#define TM_YEAR(yy) ((yy)%100)
#define sbbs_beep(f,d) BEEP(f,d)
#define mswait(x) SLEEP(x)
#define sbbs_random(x) xp_random(x)
/**************************************/
/* Text Attribute (color) Definitions */
......
......@@ -1621,8 +1621,7 @@ void DLLCALL services_thread(void* arg)
lprintf(LOG_INFO,"Compiled %s %s with %s", __DATE__, __TIME__, compiler);
srand(time(NULL)); /* Seed random number generator */
sbbs_random(10); /* Throw away first number */
sbbs_srand(); /* Seed random number generator */
if(!winsock_startup()) {
cleanup(1);
......
......@@ -2693,8 +2693,7 @@ void http_session_thread(void* arg)
thread_up(TRUE /* setuid */);
session.finished=FALSE;
srand(time(NULL)); /* Seed random number generator */
sbbs_random(10); /* Throw away first number */
sbbs_srand(); /* Seed random number generator */
if(startup->options&BBS_OPT_NO_HOST_LOOKUP)
host=NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment