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
This commit is contained in:
Nick Mathewson
2006-12-19 19:48:58 +00:00
parent 1ce86f1fca
commit bf6702cf8b
5 changed files with 25 additions and 6 deletions
+3
View File
@@ -127,6 +127,7 @@ static config_var_t _option_vars[] = {
VAR("__AllDirActionsPrivate",BOOL, AllDirActionsPrivate, "0"),
VAR("AllowInvalidNodes", CSV, AllowInvalidNodes,
"middle,rendezvous"),
VAR("AllowNonRFC953Hostnames", BOOL, AllowNonRFC953Hostnames, "0"),
VAR("AssumeReachable", BOOL, AssumeReachable, "0"),
VAR("AuthDirBadExit", LINELIST, AuthDirBadExit, NULL),
VAR("AuthDirInvalid", LINELIST, AuthDirInvalid, NULL),
@@ -354,6 +355,8 @@ static config_var_description_t options_description[] = {
/* ==== client options */
{ "AllowInvalidNodes", "Where on our circuits should Tor allow servers "
"that the directory authorities haven't called \"valid\"?" },
{ "AllowNonRFC953Hostnames", "If set to 1, we don't automatically reject "
"hostnames for having invalid characters." },
/* CircuitBuildTimeout, CircuitIdleTimeout */
{ "ClientOnly", "If set to 1, Tor will under no circumstances run as a "
"server, even if ORPort is as configued." },
+13 -3
View File
@@ -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;
}
+2
View File
@@ -1656,6 +1656,8 @@ typedef struct {
* same network zone in the same circuit. */
int TunnelDirConns; /**< If true, use BEGIN_DIR rather than BEGIN when
* possible. */
int AllowNonRFC953Hostnames; /**< If true, we allow connections to hostnames
* with weird characters. */
} or_options_t;
/** Persistent state for an onion router, as saved to disk. */