Fix a segfault

svn:r4191
This commit is contained in:
Nick Mathewson 2005-05-11 04:14:17 +00:00
parent dcc1b8a838
commit 776b411dc9

View File

@ -915,16 +915,17 @@ static int connection_ap_handshake_process_socks(connection_t *conn) {
/* foo.exit -- modify conn->chosen_exit_node to specify the exit /* foo.exit -- modify conn->chosen_exit_node to specify the exit
* node, and conn->address to hold only the address portion.*/ * node, and conn->address to hold only the address portion.*/
char *s = strrchr(socks->address,'.'); char *s = strrchr(socks->address,'.');
if (s && s[1] != '\0') { if (s) {
conn->chosen_exit_name = tor_strdup(s+1); if (s[1] != '\0') {
*s = 0; conn->chosen_exit_name = tor_strdup(s+1);
} else if (s[1] == '\0') { *s = 0;
log_fn(LOG_WARN,"Malformed exit address '%s.exit'. Refusing.", } else {
safe_str(socks->address)); log_fn(LOG_WARN,"Malformed exit address '%s.exit'. Refusing.",
connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL); safe_str(socks->address));
return -1; connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
return -1;
}
} else { } else {
tor_assert(!s); /* address is of the form server.exit. */
struct in_addr in; struct in_addr in;
routerinfo_t *r = router_get_by_nickname(socks->address); routerinfo_t *r = router_get_by_nickname(socks->address);
if (r) { if (r) {