[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Backport: Fix for 152: reject malformed .onion addresses ra...
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] Backport: Fix for 152: reject malformed .onion addresses ra...
- From: nickm@xxxxxxxx (Nick Mathewson)
- Date: Tue, 7 Jun 2005 14:03:35 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 07 Jun 2005 14:03:47 -0400
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv21982/src/or
Modified Files:
Tag: tor-0_1_0-patches
connection_edge.c or.h test.c
Log Message:
Backport: Fix for 152: reject malformed .onion addresses rather then passing them on
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.327
retrieving revision 1.327.2.1
diff -u -d -r1.327 -r1.327.2.1
--- connection_edge.c 17 May 2005 17:01:36 -0000 1.327
+++ connection_edge.c 7 Jun 2005 18:03:33 -0000 1.327.2.1
@@ -911,6 +911,12 @@
*/
addresstype = parse_extended_hostname(socks->address);
+ if (addresstype == BAD_HOSTNAME) {
+ log_fn(LOG_WARN, "Invalid hostname %s; rejecting", socks->address);
+ connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
+ return -1;
+ }
+
if (addresstype == EXIT_HOSTNAME) {
/* foo.exit -- modify conn->chosen_exit_node to specify the exit
* node, and conn->address to hold only the address portion.*/
@@ -1712,6 +1718,6 @@
failed:
/* otherwise, return to previous state and return 0 */
*s = '.';
- return NORMAL_HOSTNAME;
+ return BAD_HOSTNAME;
}
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.610
retrieving revision 1.610.2.1
diff -u -d -r1.610 -r1.610.2.1
--- or.h 23 May 2005 05:20:52 -0000 1.610
+++ or.h 7 Jun 2005 18:03:33 -0000 1.610.2.1
@@ -1377,7 +1377,7 @@
void set_exit_redirects(smartlist_t *lst);
typedef enum hostname_type_t {
- NORMAL_HOSTNAME, ONION_HOSTNAME, EXIT_HOSTNAME
+ NORMAL_HOSTNAME, ONION_HOSTNAME, EXIT_HOSTNAME, BAD_HOSTNAME
} hostname_type_t;
hostname_type_t parse_extended_hostname(char *address);
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/test.c,v
retrieving revision 1.178
retrieving revision 1.178.2.1
diff -u -d -r1.178 -r1.178.2.1
--- test.c 4 Jun 2005 13:43:03 -0000 1.178
+++ test.c 7 Jun 2005 18:03:33 -0000 1.178.2.1
@@ -1384,6 +1384,7 @@
char address1[] = "fooaddress.onion";
char address2[] = "aaaaaaaaaaaaaaaa.onion";
char address3[] = "fooaddress.exit";
+ char address4[] = "tor.eff.org";
rend_service_descriptor_t *d1, *d2;
char *encoded;
size_t len;
@@ -1412,9 +1413,10 @@
test_streq(d2->intro_points[1], "crow");
test_streq(d2->intro_points[2], "joel");
- test_eq(NORMAL_HOSTNAME, parse_extended_hostname(address1));
+ test_eq(BAD_HOSTNAME, parse_extended_hostname(address1));
test_eq(ONION_HOSTNAME, parse_extended_hostname(address2));
test_eq(EXIT_HOSTNAME, parse_extended_hostname(address3));
+ test_eq(NORMAL_HOSTNAME, parse_extended_hostname(address4));
rend_service_descriptor_free(d1);
rend_service_descriptor_free(d2);