Make the RANDOM_LOCAL_PORTS setting actually use a random port.

The code was calling random_number(65535 - 1024), but a non-zero argument
to random_number() is actually a seed to reseed the generator, and causes
random_number() to return zero.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@331 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2013-08-15 15:06:21 +00:00
parent 176be1cff2
commit 0b0dbf5cf7
2 changed files with 4 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2c01]
* Make RANDOM_LOCAL_PORTS actually random. (caf)
* Show same message on local terminal as used in emergency exit QUIT. (caf)
* Remove unused XLINK CTCP reply handler. (caf)

View File

@@ -622,7 +622,7 @@ DCC_List *new_i;
* generate a random port to use.
*/
if (!port && get_int_var(RANDOM_LOCAL_PORTS_VAR))
portnum = random_number(65535 - 1024) + 1024;
portnum = random_number(0) % (65536 - 1024) + 1024;
if (get_int_var(DCC_FORCE_PORT_VAR))
portnum = get_int_var(DCC_FORCE_PORT_VAR);
@@ -637,7 +637,7 @@ DCC_List *new_i;
* random local ports is on, try a random port.
*/
if(port && get_int_var(RANDOM_LOCAL_PORTS_VAR))
portnum = random_number(65535 - 1024) + 1024;
portnum = random_number(0) % (65536 - 1024) + 1024;
else
portnum = 0;
if ((s = connect_by_number(NULL, &portnum, SERVICE_SERVER, PROTOCOL_TCP, 1)) < 0)