connection_handle_event_cb() should handle orconns correctly even when not in OR_CONN_STATE_CONNECTING
This code is in connection_handle_event_cb():
if (conn->type == CONN_TYPE_OR &&
conn->state == OR_CONN_STATE_CONNECTING) {
connection_or_connect_failed(TO_OR_CONN(conn),
errno_to_orconn_end_reason(socket_error),
tor_socket_strerror(socket_error));
}
It should be something like this:
if (conn->type == CONN_TYPE_OR) {
if (conn->state == OR_CONN_STATE_CONNECTING) {
connection_or_connect_failed(TO_OR_CONN(conn),
errno_to_orconn_end_reason(socket_error),
tor_socket_strerror(socket_error));
} else {
connection_or_close_for_error(TO_OR_CONN(conn));
}
}
As it stands, if conn->state != OR_CONN_STATE_CONNECTING this code will incorrectly treat orconns as generic conns and call connection_mark_for_close() on them without properly notifying the channel layer.
Note that since this code is specific to bufferevents which do not currently work, this bug cannot be demonstrated in any working build of Tor, so I'm assigning it to the 0.2.?? milestone.
Created pursuant to connection_mark_for_close() audit task legacy/trac#7472 (moved).