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:
@@ -1,5 +1,7 @@
|
|||||||
[Changes 1.2c01]
|
[Changes 1.2c01]
|
||||||
|
|
||||||
|
* Make RANDOM_LOCAL_PORTS actually random. (caf)
|
||||||
|
|
||||||
* Show same message on local terminal as used in emergency exit QUIT. (caf)
|
* Show same message on local terminal as used in emergency exit QUIT. (caf)
|
||||||
|
|
||||||
* Remove unused XLINK CTCP reply handler. (caf)
|
* Remove unused XLINK CTCP reply handler. (caf)
|
||||||
|
|||||||
@@ -622,7 +622,7 @@ DCC_List *new_i;
|
|||||||
* generate a random port to use.
|
* generate a random port to use.
|
||||||
*/
|
*/
|
||||||
if (!port && get_int_var(RANDOM_LOCAL_PORTS_VAR))
|
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))
|
if (get_int_var(DCC_FORCE_PORT_VAR))
|
||||||
portnum = 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.
|
* random local ports is on, try a random port.
|
||||||
*/
|
*/
|
||||||
if(port && get_int_var(RANDOM_LOCAL_PORTS_VAR))
|
if(port && get_int_var(RANDOM_LOCAL_PORTS_VAR))
|
||||||
portnum = random_number(65535 - 1024) + 1024;
|
portnum = random_number(0) % (65536 - 1024) + 1024;
|
||||||
else
|
else
|
||||||
portnum = 0;
|
portnum = 0;
|
||||||
if ((s = connect_by_number(NULL, &portnum, SERVICE_SERVER, PROTOCOL_TCP, 1)) < 0)
|
if ((s = connect_by_number(NULL, &portnum, SERVICE_SERVER, PROTOCOL_TCP, 1)) < 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user