mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Actually pick a random port when "auto" is specified
ddc65e2b33 had broken this
This commit is contained in:
committed by
Nick Mathewson
parent
2dc40b9c49
commit
6a06f45b04
@@ -111,6 +111,15 @@ typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#define HAVE_UINT32_T
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX 0xffffu
|
||||
#endif
|
||||
#ifndef INT16_MAX
|
||||
#define INT16_MAX 0x7fff
|
||||
#endif
|
||||
#ifndef INT16_MIN
|
||||
#define INT16_MIN (-INT16_MAX-1)
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX 0xffffffffu
|
||||
#endif
|
||||
|
||||
+3
-1
@@ -1787,6 +1787,8 @@ retry_listener_ports(smartlist_t *old_conns,
|
||||
socklen_t listensocklen = 0;
|
||||
char *address=NULL;
|
||||
connection_t *conn;
|
||||
int real_port = port->port == CFG_AUTO_PORT ? 0 : port->port;
|
||||
tor_assert(real_port <= UINT16_MAX);
|
||||
|
||||
if (port->is_unix_addr) {
|
||||
listensockaddr = (struct sockaddr *)
|
||||
@@ -1795,7 +1797,7 @@ retry_listener_ports(smartlist_t *old_conns,
|
||||
} else {
|
||||
listensockaddr = tor_malloc(sizeof(struct sockaddr_storage));
|
||||
listensocklen = tor_addr_to_sockaddr(&port->addr,
|
||||
port->port,
|
||||
real_port,
|
||||
listensockaddr,
|
||||
sizeof(struct sockaddr_storage));
|
||||
address = tor_dup_addr(&port->addr);
|
||||
|
||||
Reference in New Issue
Block a user