mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Merge branch 'bug9400_024_squashed' into maint-0.2.4
This commit is contained in:
commit
a8e76de4d9
7
changes/bug9400
Normal file
7
changes/bug9400
Normal file
@ -0,0 +1,7 @@
|
||||
o Minor bugfixes:
|
||||
|
||||
- Avoid double-closing the listener socket in our socketpair replacement
|
||||
(used on Windows) in the case where the addresses on our opened
|
||||
sockets don't match what we expected. Fixes bug 9400; bugfix on
|
||||
every released Tor version. Found by Coverity.
|
||||
|
@ -1225,9 +1225,9 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
||||
* for now, and really, when localhost is down sometimes, we
|
||||
* have other problems too.
|
||||
*/
|
||||
tor_socket_t listener = -1;
|
||||
tor_socket_t connector = -1;
|
||||
tor_socket_t acceptor = -1;
|
||||
tor_socket_t listener = TOR_INVALID_SOCKET;
|
||||
tor_socket_t connector = TOR_INVALID_SOCKET;
|
||||
tor_socket_t acceptor = TOR_INVALID_SOCKET;
|
||||
struct sockaddr_in listen_addr;
|
||||
struct sockaddr_in connect_addr;
|
||||
int size;
|
||||
@ -1281,7 +1281,6 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
||||
goto tidy_up_and_fail;
|
||||
if (size != sizeof(listen_addr))
|
||||
goto abort_tidy_up_and_fail;
|
||||
tor_close_socket(listener);
|
||||
/* Now check we are talking to ourself by matching port and host on the
|
||||
two sockets. */
|
||||
if (getsockname(connector, (struct sockaddr *) &connect_addr, &size) == -1)
|
||||
@ -1292,6 +1291,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
||||
|| listen_addr.sin_port != connect_addr.sin_port) {
|
||||
goto abort_tidy_up_and_fail;
|
||||
}
|
||||
tor_close_socket(listener);
|
||||
fd[0] = connector;
|
||||
fd[1] = acceptor;
|
||||
|
||||
@ -1306,11 +1306,11 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|
||||
tidy_up_and_fail:
|
||||
if (saved_errno < 0)
|
||||
saved_errno = errno;
|
||||
if (listener != -1)
|
||||
if (SOCKET_OK(listener))
|
||||
tor_close_socket(listener);
|
||||
if (connector != -1)
|
||||
if (SOCKET_OK(connector))
|
||||
tor_close_socket(connector);
|
||||
if (acceptor != -1)
|
||||
if (SOCKET_OK(acceptor))
|
||||
tor_close_socket(acceptor);
|
||||
return -saved_errno;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user