[tor-bugs] #14900 [Tor]: To link connections only if they ready

Tor Bug Tracker & Wiki blackhole at torproject.org
Sat Feb 14 16:52:33 UTC 2015


#14900: To link connections only if they ready
-------------------------+---------------------
 Reporter:  cypherpunks  |          Owner:
     Type:  defect       |         Status:  new
 Priority:  normal       |      Milestone:
Component:  Tor          |        Version:
 Keywords:               |  Actual Points:
Parent ID:               |         Points:
-------------------------+---------------------
 ''connection_exit_connect_dir'' and ''connection_ap_make_link'' creates
 linked pair for connections that can be freed before ''connection_unlink''
 thus invalidates ''linked_conn''.

 {{{
   connection_link_connections(partner, base_conn);

   if (connection_add(base_conn) < 0) { /* no space, forget it */
     connection_free(base_conn);
     return NULL;
   }
 }}}

 {{{
   connection_link_connections(TO_CONN(dirconn), TO_CONN(exitconn));

   if (connection_add(TO_CONN(exitconn))<0) {
     connection_edge_end(exitconn, END_STREAM_REASON_RESOURCELIMIT);
     connection_free(TO_CONN(exitconn));
     connection_free(TO_CONN(dirconn));
     return 0;
   }

   /* link exitconn to circ, now that we know we can use it. */
   exitconn->next_stream = circ->n_streams;
   circ->n_streams = exitconn;

   if (connection_add(TO_CONN(dirconn))<0) {
     connection_edge_end(exitconn, END_STREAM_REASON_RESOURCELIMIT);
     connection_close_immediate(TO_CONN(exitconn));
     connection_mark_for_close(TO_CONN(exitconn));
     connection_free(TO_CONN(dirconn));
     return 0;
   }
 }}}
 If ''connection_add'' fails then ''linked_conn'' from another connection
 is broken. (currently it can to fail only if BUFFEREVENTS used by code)

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/14900>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list