obfsproxy: pending_socks_cb() proceeds even if getpeername() fails.
network.c:pending_socks_cb()
:
...
/* Figure out where we actually connected to, and tell the socks client */
if (getpeername(bufferevent_getfd(bev), sa, &slen) == 0) {
socks_state_set_address(socks, sa);
if (!down->peername)
down->peername = printable_address(sa, slen);
}
socks_send_reply(socks, bufferevent_get_output(up->buffer), 0);
...
If getpeername() fails, we shouldn't proceed with sending a positive SOCKS reply.
socks_send_reply
also messes around with socks_state_t.parsereq which is not filled if socks_state_set_address
was not called.