mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
make control interface stream IDs monotonically increasing to prevent possible races
svn:r3715
This commit is contained in:
parent
349ee1abea
commit
b7b05dc1b2
@ -110,6 +110,7 @@ static int connection_bucket_read_limit(connection_t *conn);
|
||||
* Initialize conn's timestamps to now.
|
||||
*/
|
||||
connection_t *connection_new(int type) {
|
||||
static uint32_t n_connections_allocated = 0;
|
||||
connection_t *conn;
|
||||
time_t now = time(NULL);
|
||||
|
||||
@ -117,6 +118,7 @@ connection_t *connection_new(int type) {
|
||||
conn->magic = CONNECTION_MAGIC;
|
||||
conn->s = -1; /* give it a default of 'not used' */
|
||||
conn->poll_index = -1; /* also default to 'not used' */
|
||||
conn->global_identifier = n_connections_allocated++;
|
||||
|
||||
conn->type = type;
|
||||
if (!connection_is_listener(conn)) { /* listeners never use their buf */
|
||||
|
@ -769,7 +769,7 @@ control_event_stream_status(connection_t *conn, stream_status_event_t tp)
|
||||
len = strlen(buf);
|
||||
msg = tor_malloc(5+len+1);
|
||||
msg[0] = (uint8_t) tp;
|
||||
set_uint32(msg+1, htonl(conn->s)); /* ???? Is this a security problem? */
|
||||
set_uint32(msg+1, htonl(conn->global_identifier));
|
||||
strlcpy(msg+5, buf, len+1);
|
||||
|
||||
send_control_event(EVENT_STREAM_STATUS, (uint16_t)(5+len+1), msg);
|
||||
|
@ -598,6 +598,10 @@ struct connection_t {
|
||||
socks_request_t *socks_request; /**< SOCKS structure describing request (AP
|
||||
* only.) */
|
||||
|
||||
/** Quasi-global identifier for this connection; used for control.c */
|
||||
/* XXXX NM This can get re-used after 2**32 circuits. */
|
||||
uint32_t global_identifier;
|
||||
|
||||
/* Used only by control connections */
|
||||
uint32_t event_mask;
|
||||
};
|
||||
@ -874,7 +878,7 @@ struct circuit_t {
|
||||
struct circuit_t *rend_splice;
|
||||
|
||||
/** Quasi-global identifier for this circuit; used for control.c */
|
||||
/* XXXX009 NM This can get re-used after 2**32 circuits. */
|
||||
/* XXXX NM This can get re-used after 2**32 circuits. */
|
||||
uint32_t global_identifier;
|
||||
|
||||
struct circuit_t *next; /**< Next circuit in linked list. */
|
||||
|
Loading…
Reference in New Issue
Block a user