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
This commit is contained in:
Nick Mathewson
2007-10-14 08:48:51 +00:00
parent 172773cf55
commit dd44c068c5
3 changed files with 14 additions and 2 deletions
+2
View File
@@ -31,6 +31,8 @@ Changes in version 0.1.2.18 - 2007-??-??
- When we have our clock set far in the future and generate an onion key,
then re-set our clock to be correct, we should not stop the onion
key from getting rotated.
- On some platforms, accept() can return a broken address. Detect
this more quietly, and deal accordingly. (Fixes bug 483.)
Changes in version 0.1.2.17 - 2007-08-30
+1 -1
View File
@@ -3,7 +3,7 @@ description of the patch.)
Backport items for 0.1.2:
o r11166: Don't believe future dates from the state file.
N - r11828+: Detect bad sa_family from accept().
o r11828+: Detect bad sa_family from accept().
N - r11882: Avoid crash-bug 451.
N - r11886: Consider family as well as identity when cannibalizing circuits.
+11 -1
View File
@@ -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,