summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/or/connection.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index b67cd1e2cc..23a0be1fdd 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -931,7 +931,15 @@ connection_handle_listener_read(connection_t *conn, int new_type)
if (options->ConstrainedSockets)
set_constrained_socket_buffers(news, (int)options->ConstrainedSockSize);
- tor_assert(((struct sockaddr*)addrbuf)->sa_family == conn->socket_family);
+ if (((struct sockaddr*)addrbuf)->sa_family != conn->socket_family) {
+ log_warn(LD_BUG, "A listener connection returned a socket with a "
+ "mismatched family. %s for addr_family %d gave us a socket "
+ "with address family %d.", conn_type_to_string(conn->type),
+ (int)conn->socket_family,
+ (int)((struct sockaddr*)addrbuf)->sa_family);
+ tor_close_socket(news);
+ return 0;
+ }
if (conn->socket_family == AF_INET) {
if (check_sockaddr_in((struct sockaddr*)addrbuf, remotelen, LOG_INFO)<0) {