diff options
author | Yawning Angel <yawning@schwanenlied.me> | 2015-06-24 13:52:29 +0000 |
---|---|---|
committer | Yawning Angel <yawning@schwanenlied.me> | 2015-06-24 13:52:29 +0000 |
commit | 3f336966a264d7cd7c6dab08fb85d85273f06d68 (patch) | |
tree | 5c25761adefefba6037dedab2d4c881cca715f1d /src/common/util.c | |
parent | 8b35d8508835f23b8e804982db368c0304a08d40 (diff) | |
download | tor-3f336966a264d7cd7c6dab08fb85d85273f06d68.tar.gz tor-3f336966a264d7cd7c6dab08fb85d85273f06d68.zip |
Work around nytimes.com's broken hostnames in our SOCKS checks.
RFC 952 is approximately 30 years old, and people are failing to comply,
by serving A records with '_' as part of the hostname. Since relaxing
the check is a QOL improvement for our userbase, relax the check to
allow such abominations as destinations, especially since there are
likely to be other similarly misconfigured domains out there.
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/util.c b/src/common/util.c index 942d0c290e..449015054f 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -1036,6 +1036,9 @@ string_is_valid_ipv6_address(const char *string) /** Return true iff <b>string</b> matches a pattern of DNS names * that we allow Tor clients to connect to. + * + * Note: This allows certain technically invalid characters ('_') to cope + * with misconfigured zones that have been encountered in the wild. */ int string_is_valid_hostname(const char *string) @@ -1048,7 +1051,7 @@ string_is_valid_hostname(const char *string) smartlist_split_string(components,string,".",0,0); SMARTLIST_FOREACH_BEGIN(components, char *, c) { - if (c[0] == '-') { + if ((c[0] == '-') || (*c == '_')) { result = 0; break; } @@ -1057,7 +1060,7 @@ string_is_valid_hostname(const char *string) if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || - (*c == '-')) + (*c == '-') || (*c == '_')) c++; else result = 0; |