[or-cvs] make control interface stream IDs monotonically increasing ...
Nick Mathewson
nickm at seul.org
Tue Mar 1 01:15:04 UTC 2005
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv23016/src/or
Modified Files:
or.h control.c connection.c
Log Message:
make control interface stream IDs monotonically increasing to prevent possible races
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.544
retrieving revision 1.545
diff -u -d -r1.544 -r1.545
--- or.h 28 Feb 2005 22:38:00 -0000 1.544
+++ or.h 1 Mar 2005 01:15:00 -0000 1.545
@@ -598,6 +598,10 @@
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 *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. */
Index: control.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/control.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- control.c 27 Feb 2005 23:20:48 -0000 1.45
+++ control.c 1 Mar 2005 01:15:00 -0000 1.46
@@ -769,7 +769,7 @@
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);
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.332
retrieving revision 1.333
diff -u -d -r1.332 -r1.333
--- connection.c 28 Feb 2005 02:52:51 -0000 1.332
+++ connection.c 1 Mar 2005 01:15:01 -0000 1.333
@@ -110,6 +110,7 @@
* 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 @@
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 */
More information about the tor-commits
mailing list