backport candidate:

If a directory server runs out of space in the connection table
as it's processing a begin_dir request, it will free the exit stream
but leave it attached to the circuit, leading to unpredictable
behavior. (Reported by seeess, fixes bug 425.)


svn:r10154
This commit is contained in:
Roger Dingledine 2007-05-10 08:53:05 +00:00
parent cd23b65a07
commit 5ffabd4de4
2 changed files with 24 additions and 14 deletions

View File

@ -29,6 +29,12 @@ Changes in version 0.2.0.1-alpha - 2007-??-??
in the network. Implements proposal 107, suggested by Kevin Bauer in the network. Implements proposal 107, suggested by Kevin Bauer
and Damon McCoy. and Damon McCoy.
o Crash fixes:
- If a directory server runs out of space in the connection table
as it's processing a begin_dir request, it will free the exit stream
but leave it attached to the circuit, leading to unpredictable
behavior. (Reported by seeess, fixes bug 425.)
o Minor fixes (resource management): o Minor fixes (resource management):
- Count the number of open sockets separately from the number of active - Count the number of open sockets separately from the number of active
connection_t objects. This will let us avoid underusing our connection_t objects. This will let us avoid underusing our
@ -40,8 +46,8 @@ Changes in version 0.2.0.1-alpha - 2007-??-??
the server), and avoids the nasty Windows socketpair() workaround. the server), and avoids the nasty Windows socketpair() workaround.
- Keep unused 4k and 16k buffers on free lists, rather than wasting 8k - Keep unused 4k and 16k buffers on free lists, rather than wasting 8k
for every single inactive connection_t. for every single inactive connection_t.
- Free items from the 4/16k-buffer free lists when they haven't been used - Free items from the 4k/16k-buffer free lists when they haven't been
for a while. used for a while.
o Minor features (build): o Minor features (build):
- Make autoconf search for libevent, openssl, and zlib consistently. - Make autoconf search for libevent, openssl, and zlib consistently.

View File

@ -29,7 +29,8 @@ static smartlist_t *redirect_exit_list = NULL;
static int connection_ap_handshake_process_socks(edge_connection_t *conn); static int connection_ap_handshake_process_socks(edge_connection_t *conn);
static int connection_ap_process_natd(edge_connection_t *conn); static int connection_ap_process_natd(edge_connection_t *conn);
static int connection_exit_connect_dir(edge_connection_t *exit_conn); static int connection_exit_connect_dir(edge_connection_t *exit_conn,
or_circuit_t *circ);
static int hostname_is_noconnect_address(const char *address); static int hostname_is_noconnect_address(const char *address);
/** An AP stream has failed/finished. If it hasn't already sent back /** An AP stream has failed/finished. If it hasn't already sent back
@ -2218,19 +2219,18 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
connection_free(TO_CONN(n_stream)); connection_free(TO_CONN(n_stream));
return 0; return 0;
} }
log_debug(LD_EXIT,"about to start the dns_resolve().");
if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
if (or_circ && or_circ->p_conn && or_circ->p_conn->_base.addr)
n_stream->_base.addr = or_circ->p_conn->_base.addr;
n_stream->next_stream = TO_OR_CIRCUIT(circ)->n_streams;
n_stream->on_circuit = circ;
TO_OR_CIRCUIT(circ)->n_streams = n_stream;
return connection_exit_connect_dir(n_stream);
}
n_stream->on_circuit = circ; n_stream->on_circuit = circ;
if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
tor_assert(or_circ);
if (or_circ->p_conn && or_circ->p_conn->_base.addr)
n_stream->_base.addr = or_circ->p_conn->_base.addr;
return connection_exit_connect_dir(n_stream, or_circ);
}
log_debug(LD_EXIT,"about to start the dns_resolve().");
/* send it off to the gethostbyname farm */ /* send it off to the gethostbyname farm */
switch (dns_resolve(n_stream)) { switch (dns_resolve(n_stream)) {
case 1: /* resolve worked */ case 1: /* resolve worked */
@ -2399,7 +2399,8 @@ connection_exit_connect(edge_connection_t *edge_conn)
* DOCDOC no longer uses socketpair * DOCDOC no longer uses socketpair
*/ */
static int static int
connection_exit_connect_dir(edge_connection_t *exit_conn) connection_exit_connect_dir(edge_connection_t *exit_conn,
or_circuit_t *circ)
{ {
dir_connection_t *dir_conn = NULL; dir_connection_t *dir_conn = NULL;
@ -2425,6 +2426,9 @@ connection_exit_connect_dir(edge_connection_t *exit_conn)
return 0; return 0;
} }
exit_conn->next_stream = circ->n_streams;
circ->n_streams = exit_conn;
if (connection_add(TO_CONN(dir_conn))<0) { if (connection_add(TO_CONN(dir_conn))<0) {
connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT); connection_edge_end(exit_conn, END_STREAM_REASON_RESOURCELIMIT);
connection_close_immediate(TO_CONN(exit_conn)); connection_close_immediate(TO_CONN(exit_conn));