[PATCH] Implement proposal xxx: ignore subdomains in hidden service addresses

The implementation is pretty straightforward: parse_extended_hostname() is modified to drop any leading components from an address like 'foo.aaaaaaaaaaaaaaaa.onion'. --- Warning! Tests on this patch were limited to 'make check'. src/or/connection_edge.c | 10 +++++++++- src/test/test.c | 4 ++++ 2 files changed, 13 insertions(+), 1 deletions(-) diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 3c8b4bc..92a3dbe 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -3490,6 +3490,7 @@ hostname_type_t parse_extended_hostname(char *address) { char *s; + char *q; char query[REND_SERVICE_ID_LEN_BASE32+1]; s = strrchr(address,'.'); @@ -3504,9 +3505,16 @@ parse_extended_hostname(char *address) /* so it is .onion */ *s = 0; /* NUL-terminate it */ - if (strlcpy(query, address, REND_SERVICE_ID_LEN_BASE32+1) >= + /* if there is a 'sub-domain' component, just remove it + * (see proposal XXX) */ + q = strrchr(address, '.'); + q = (NULL == q) ? address : q + 1; + if (strlcpy(query, q, REND_SERVICE_ID_LEN_BASE32+1) >= REND_SERVICE_ID_LEN_BASE32+1) goto failed; + if (q != address) { + memmove(address, q, strlen(q)); + } if (rend_valid_service_id(query)) { return ONION_HOSTNAME; /* success */ } diff --git a/src/test/test.c b/src/test/test.c index 454fc54..3edf02f 100644 --- a/src/test/test.c +++ b/src/test/test.c @@ -1289,11 +1289,15 @@ test_rend_fns(void) char address2[] = "aaaaaaaaaaaaaaaa.onion"; char address3[] = "fooaddress.exit"; char address4[] = "www.torproject.org"; + char address5[] = "foo.aaaaaaaaaaaaaaaa.onion"; + char address6[] = "foo.bar.aaaaaaaaaaaaaaaa.onion"; test_assert(BAD_HOSTNAME == parse_extended_hostname(address1)); test_assert(ONION_HOSTNAME == parse_extended_hostname(address2)); test_assert(EXIT_HOSTNAME == parse_extended_hostname(address3)); test_assert(NORMAL_HOSTNAME == parse_extended_hostname(address4)); + test_assert(ONION_HOSTNAME == parse_extended_hostname(address5)); + test_assert(ONION_HOSTNAME == parse_extended_hostname(address6)); pk1 = pk_generate(0); pk2 = pk_generate(1); -- 1.7.2.5

Looks On Fri, Jul 6, 2012 at 10:56 AM, Jérémy Bobbio <lunar@debian.org> wrote:
The implementation is pretty straightforward: parse_extended_hostna me() is modified to drop any leading components from an address like 'foo.aaaaaaaaaaaaaaaa.onion'.
Looks good except for a few things: * It needs a "changes" file; see doc/HACKING for the format there. * The documentation for the function doesn't say that it accepts the new syntax, and doesn't say that it removes the leading material from the hostname. * It considers .aaaaaaaaaaaaaaa.onion to be a valid hostname; is that wrong? * The tests should probably make sure that it modifies the hostname as expected
Warning! Tests on this patch were limited to 'make check'.
* Somebody should run this to make sure that it works. :) BTW, it's usually a good idea to put patches on the bugtracker at trac.torproject.org: that way it is way harder for me to forget about them, drop them on the floor, or anything like that. cheers, -- Nick

On Sat, Jul 07, 2012 at 01:13:52PM -0400, Nick Mathewson wrote:
Looks good except for a few things:
* It needs a "changes" file; see doc/HACKING for the format there. * The documentation for the function doesn't say that it accepts the new syntax, and doesn't say that it removes the leading material from the hostname. * It considers .aaaaaaaaaaaaaaa.onion to be a valid hostname; is that wrong? * The tests should probably make sure that it modifies the hostname as expected
v2 fixes all these issues.
Warning! Tests on this patch were limited to 'make check'.
* Somebody should run this to make sure that it works. :)
Still not done. :D
BTW, it's usually a good idea to put patches on the bugtracker at trac.torproject.org: that way it is way harder for me to forget about them, drop them on the floor, or anything like that.
Done: <https://trac.torproject.org/projects/tor/ticket/6344> I was waiting for the proposal to gets its number, I guess. Let's move the discussion on the ticket from now on. -- Jérémy Bobbio .''`. lunar@debian.org : :Ⓐ : # apt-get install anarchism `. `'` `-
participants (2)
-
Jérémy Bobbio
-
Nick Mathewson