[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Apply patch from Geoff for bug 132. Clean it up a little t...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Apply patch from Geoff for bug 132. Clean it up a little t...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Tue, 10 May 2005 18:12:51 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 10 May 2005 18:13:08 -0400
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv5348
Modified Files:
connection_edge.c
Log Message:
Apply patch from Geoff for bug 132. Clean it up a little to fix a memory leak and to avoid unnecessary parse/unparse code.
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.324
retrieving revision 1.325
diff -u -d -r1.324 -r1.325
--- connection_edge.c 7 May 2005 05:55:06 -0000 1.324
+++ connection_edge.c 10 May 2005 22:12:48 -0000 1.325
@@ -912,16 +912,34 @@
addresstype = parse_extended_hostname(socks->address);
if (addresstype == EXIT_HOSTNAME) {
- /* .exit -- modify conn to specify the exit node. */
+ /* foo.exit -- modify conn->chosen_exit_node to specify the exit
+ * node, and conn->address to hold only the address portion.*/
char *s = strrchr(socks->address,'.');
- if (!s || s[1] == '\0') {
- log_fn(LOG_WARN,"Malformed exit address '%s'. Refusing.",
+ if (s && s[1] != '\0') {
+ conn->chosen_exit_name = tor_strdup(s+1);
+ *s = 0;
+ } else if (s[1] == '\0') {
+ log_fn(LOG_WARN,"Malformed exit address '%s.exit'. Refusing.",
safe_str(socks->address));
connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
return -1;
+ } else {
+ tor_assert(!s); /* address is of the form server.exit. */
+ struct in_addr in;
+ routerinfo_t *r = router_get_by_nickname(socks->address);
+ if (r) {
+ conn->chosen_exit_name = tor_strdup(socks->address);
+ /* XXXX Should this use server->address instead? */
+ in.s_addr = htonl(r->addr);
+ strlcpy(socks->address, inet_ntoa(in), sizeof(socks->address));
+ } else {
+ log_fn(LOG_WARN,
+ "Unrecognized server in exit address '%s.exit'. Refusing.",
+ safe_str(socks->address));
+ connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
+ return -1;
+ }
}
- conn->chosen_exit_name = tor_strdup(s+1);
- *s = 0;
}
if (addresstype != ONION_HOSTNAME) {