]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix some #5040 bugs found by Nick's tests.
authorGeorge Kadianakis <desnacked@riseup.net>
Mon, 5 Aug 2013 16:08:14 +0000 (19:08 +0300)
committerNick Mathewson <nickm@torproject.org>
Thu, 15 Aug 2013 16:03:38 +0000 (12:03 -0400)
- Set conn->address when we receive a USERADDR command.
- Set conn->state to a sane value when we transition from Extended
  ORPort to ORPort.

src/or/ext_orport.c
src/test/test_extorport.c

index fdcecacda217c8bf4e905b4ffcd3dbc1984abefa..d5a0fa1ee4071acd752fc905007e2eccafa8e0e0 100644 (file)
@@ -80,6 +80,7 @@ connection_ext_or_transition(or_connection_t *conn)
   tor_assert(conn->base_.type == CONN_TYPE_EXT_OR);
 
   conn->base_.type = CONN_TYPE_OR;
+  TO_CONN(conn)->state = 0; // set the state to a neutral value
   control_event_or_conn_status(conn, OR_CONN_EVENT_NEW, 0);
   connection_tls_start_handshake(conn, 1);
 }
@@ -474,6 +475,10 @@ connection_ext_or_handle_cmd_useraddr(connection_t *conn,
   /* record the address */
   tor_addr_copy(&conn->addr, &addr);
   conn->port = port;
+  if (conn->address) {
+    tor_free(conn->address);
+  }
+  conn->address = tor_dup_addr(&addr);
 
   return 0;
 }
index e76808fa9c226ea6a20e0a503ba23f25e1298f4f..b32ca35ffba0654e15230c98cdf2719b9189294a 100644 (file)
@@ -505,10 +505,7 @@ test_ext_or_handshake(void *arg)
   tt_int_op(is_reading,==,1);
   tt_int_op(handshake_start_called,==,1);
   tt_int_op(TO_CONN(conn)->type, ==, CONN_TYPE_OR);
-  /* XXXXX the state is now nonsensical! It should be set to something
-   * neutral (zero?) before we connection_or_change_state; right now
-   * it's EXT_OR_CONN_STATE_FLUSHING */
-  /* tt_int_op(TO_CONN(conn)->state, ==, 0); XXXX */
+  tt_int_op(TO_CONN(conn)->state, ==, 0);
 
  done:
   UNMOCK(connection_write_to_buf_impl_);