]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Don't fail to send netinfo if real_addr is unset
authorSebastian Hahn <sebastian@torproject.org>
Wed, 16 Nov 2011 13:07:10 +0000 (14:07 +0100)
committerSebastian Hahn <sebastian@torproject.org>
Wed, 16 Nov 2011 15:05:46 +0000 (16:05 +0100)
If we haven't set real_addr on a connection, we also now that _base.addr
hasn't been tampered with. So we can use that.

src/or/connection_or.c

index 18ee0dfcf8bc1f7dbee8bdbf53cdf2fe5bf9edab..320d8cb50108219f6b17f80eb760e835c9225ed9 100644 (file)
@@ -1923,7 +1923,11 @@ connection_or_send_netinfo(or_connection_t *conn)
 
   /* Their address. */
   out = cell.payload + 4;
-  len = append_address_to_payload(out, &conn->real_addr);
+  /* We use &conn->real_addr below, unless it hasn't yet been set. If it
+   * hasn't yet been set, we know that _base.addr hasn't been tampered with
+   * yet either. */
+  len = append_address_to_payload(out, !tor_addr_is_null(&conn->real_addr)
+                                       ? &conn->real_addr : &conn->_base.addr);
   if (len<0)
     return -1;
   out += len;