summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-14 08:48:51 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-14 08:48:51 +0000
commitdd44c068c5b962c26efd52c0ae013f281b743d8e (patch)
tree5388d730965241417182a15d8b221ee41d33e3d6 /src/or
parent172773cf558b7888a10d918bf850634752842dc0 (diff)
downloadtor-dd44c068c5b962c26efd52c0ae013f281b743d8e.tar.gz
tor-dd44c068c5b962c26efd52c0ae013f281b743d8e.zip
r15761@catbus: nickm | 2007-10-14 04:24:18 -0400
backport r11828: when accept gives us something we didn't want (which means "not AF_INET" in 0.1.2.x) then warn and bail from connection_handle_listener_read(). svn:r11926
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 86fc4bf629..e92345aeb3 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -736,7 +736,7 @@ connection_handle_listener_read(connection_t *conn, int new_type)
struct sockaddr_in remote;
char addrbuf[256];
/* length of the remote address. Must be whatever accept() needs. */
- socklen_t remotelen = 256;
+ socklen_t remotelen = sizeof(addrbuf);
char tmpbuf[INET_NTOA_BUF_LEN];
tor_assert((size_t)remotelen >= sizeof(struct sockaddr_in));
memset(addrbuf, 0, sizeof(addrbuf));
@@ -762,6 +762,16 @@ connection_handle_listener_read(connection_t *conn, int new_type)
news,conn->s);
set_socket_nonblocking(news);
+ if (((struct sockaddr*)addrbuf)->sa_family != AF_INET) {
+ log_info(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. Dropping.",
+ conn_type_to_string(conn->type),
+ (int)AF_INET,
+ (int)((struct sockaddr*)addrbuf)->sa_family);
+ tor_close_socket(news);
+ return 0;
+ }
if (check_sockaddr_in((struct sockaddr*)addrbuf, remotelen, LOG_INFO)<0) {
log_info(LD_NET,