diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-02-25 07:31:46 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-02-25 07:31:46 +0000 |
commit | 496e414e5208fe4c196a645e2f64ba712d893f6e (patch) | |
tree | 50778a6e14363e60bd61d292be1e08eee2133693 /src/or/connection.c | |
parent | 1b25794a56654e115fa46ac9bfc6334753f6dda1 (diff) | |
download | tor-496e414e5208fe4c196a645e2f64ba712d893f6e.tar tor-496e414e5208fe4c196a645e2f64ba712d893f6e.tar.gz |
Basic RAM poisoning and magic-checking to notice connection and circuit
corruption faster; also, check for corruption in dns.c so we can fail fast
for the bug that's nailing Lucky and moria3.
svn:r1123
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 7c51558d2..4d7933696 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -78,8 +78,10 @@ connection_t *connection_new(int type) { time_t now = time(NULL); conn = tor_malloc_zero(sizeof(connection_t)); + conn->magic = CONNECTION_MAGIC; conn->s = -1; /* give it a default of 'not used' */ + conn->type = type; if(!connection_is_listener(conn)) { /* listeners never use their buf */ conn->inbuf = buf_new(); @@ -100,6 +102,7 @@ connection_t *connection_new(int type) { void connection_free(connection_t *conn) { assert(conn); + assert(conn->magic == CONNECTION_MAGIC); if(!connection_is_listener(conn)) { buf_free(conn->inbuf); @@ -126,6 +129,7 @@ void connection_free(connection_t *conn) { log_fn(LOG_INFO,"closing fd %d.",conn->s); close(conn->s); } + memset(conn, 0xAA, sizeof(connection_t)); /* poison memory */ free(conn); } @@ -748,8 +752,9 @@ int connection_finished_flushing(connection_t *conn) { void assert_connection_ok(connection_t *conn, time_t now) { - return; assert(conn); + assert(conn->magic == CONNECTION_MAGIC); + return; assert(conn->type >= _CONN_TYPE_MIN); assert(conn->type <= _CONN_TYPE_MAX); |