summaryrefslogtreecommitdiff
path: root/src/or/connection_edge.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-19 19:48:58 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-19 19:48:58 +0000
commitbf6702cf8b8f251356b72a8276fefbdeb6eca453 (patch)
tree196b03caa491e058c4fc7d6b3b8dc6be36420d6c /src/or/connection_edge.c
parent1ce86f1fca841b5c214bc0762507c38f04e4ab8f (diff)
downloadtor-bf6702cf8b8f251356b72a8276fefbdeb6eca453.tar.gz
tor-bf6702cf8b8f251356b72a8276fefbdeb6eca453.zip
r11645@Kushana: nickm | 2006-12-19 14:22:36 -0500
Reject hostnames with invalid characters, in an attempt to catch more errors earlier. Add an option to disable this behavior. svn:r9156
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r--src/or/connection_edge.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index be0c9a4820..ab83584140 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -1030,9 +1030,19 @@ addressmap_register_virtual_address(int type, char *new_address)
static int
address_is_invalid_destination(const char *address)
{
- /* FFFF should flesh this out */
- if (strchr(address,':'))
- return 1;
+ if (get_options()->AllowNonRFC953Hostnames)
+ return 0;
+
+ while (*address) {
+ if (TOR_ISALNUM(*address) ||
+ *address == '-' ||
+ *address == '.' ||
+ *address == '_') /* Underscore is not allowed, but Windows does it
+ * sometimes, just to thumb its nose at the IETF. */
+ ++address;
+ else
+ return 1;
+ }
return 0;
}