]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
defensive programming to catch duplicate calls to connection_init_or_handshake_state
authorNick Mathewson <nickm@torproject.org>
Thu, 27 Oct 2011 00:19:25 +0000 (20:19 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 11 Jan 2012 16:10:17 +0000 (11:10 -0500)
src/or/connection_or.c

index 7609138e68ca8156c0a94dd6b9dc63d4fb80843f..76402a557bb997e379064550882393cc4b0b4801 100644 (file)
@@ -1583,6 +1583,10 @@ int
 connection_init_or_handshake_state(or_connection_t *conn, int started_here)
 {
   or_handshake_state_t *s;
+  if (conn->handshake_state) {
+    log_warn(LD_BUG, "Duplicate call to connection_init_or_handshake_state!");
+    return 0;
+  }
   s = conn->handshake_state = tor_malloc_zero(sizeof(or_handshake_state_t));
   s->started_here = started_here ? 1 : 0;
   s->digest_sent_data = 1;