[tor-bugs] #5324 [Tor Relay]: connection_handle_read_impl() has wrong function comment?

Tor Bug Tracker & Wiki torproject-admin at torproject.org
Tue Mar 6 23:12:52 UTC 2012


#5324: connection_handle_read_impl() has wrong function comment?
-----------------------+----------------------------------------------------
 Reporter:  arma       |          Owner:                    
     Type:  defect     |         Status:  new               
 Priority:  normal     |      Milestone:  Tor: 0.2.3.x-final
Component:  Tor Relay  |        Version:                    
 Keywords:             |         Parent:                    
   Points:             |   Actualpoints:                    
-----------------------+----------------------------------------------------

Comment(by nickm):

 To answer your questions: connection_handle_read is called from
 conn_read_callback, when we could read data on the underlying connection.
 (Ignore the other case.)

 Then we do indeed get into the kind of issue you describe.  We call
 SSL_read() on the number of bytes we want (call it N), but OpenSSL can
 indeed read more than N bytes from the network if it needs to do that in
 order to get a packet, decrypt it, and read N bytes.  Moreover, we don't
 let the rest of the packet's contents sit in the SSL object's read buffer!
 Instead, we read it all, here in connection_read_to_buf():

 {{{
     pending = tor_tls_get_pending_bytes(or_conn->tls);
     if (pending) {
       /* If we have any pending bytes, we read them now.  This *can*
        * take us over our read allotment, but really we shouldn't be
        * believing that SSL bytes are the same as TCP bytes anyway. */
       int r2 = read_to_buf_tls(or_conn->tls, pending, conn->inbuf);
       if (r2<0) {
         log_warn(LD_BUG, "apparently, reading pending bytes can fail.");
         return -1;
       }
     }
 }}}

 That comment appears to be relevant. :)

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


More information about the tor-bugs mailing list