diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-03-26 16:56:31 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-03-26 16:56:31 +0000 |
commit | 6edab8569a0522ba1026c0c9c6cd1199846b819d (patch) | |
tree | 00f90ee5c5a38ae469735a5b798e6a5dcf14e3a5 | |
parent | e4ebe3409e941cf16b2a80a939848deb9e810ca3 (diff) | |
download | tor-6edab8569a0522ba1026c0c9c6cd1199846b819d.tar.gz tor-6edab8569a0522ba1026c0c9c6cd1199846b819d.zip |
r19060@catbus: nickm | 2008-03-26 12:44:19 -0400
Make v2 hidden service descriptors use the new area allocation logic. This works for me, but Karsten should definitely have a look at it.
svn:r14195
-rw-r--r-- | src/or/routerparse.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 32349cf0ee..6a1db60242 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -3311,6 +3311,7 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, smartlist_t *versions; char public_key_hash[DIGEST_LEN]; char test_desc_id[DIGEST_LEN]; + memarea_t *area = NULL; tor_assert(desc); /* Check if desc starts correctly. */ if (strncmp(desc, "rendezvous-service-descriptor ", @@ -3332,7 +3333,8 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, else eos = eos + 1; /* Tokenize descriptor. */ - if (tokenize_string(NULL, desc, eos, tokens, desc_token_table, 0)) { + area = memarea_new(4096); + if (tokenize_string(area, desc, eos, tokens, desc_token_table, 0)) { log_warn(LD_REND, "Error tokenizing descriptor."); goto err; } @@ -3428,9 +3430,9 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, "type MESSAGE"); goto err; } - *intro_points_encrypted_out = tok->object_body; + *intro_points_encrypted_out = tor_memdup(tok->object_body, + tok->object_size); *intro_points_encrypted_size_out = tok->object_size; - tok->object_body = NULL; /* Prevent free. */ } else { *intro_points_encrypted_out = NULL; *intro_points_encrypted_size_out = 0; @@ -3461,6 +3463,8 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_free(t)); smartlist_free(tokens); } + if (area) + memarea_drop_all(area); *parsed_out = result; if (result) return 0; @@ -3489,6 +3493,7 @@ rend_decrypt_introduction_points(rend_service_descriptor_t *parsed, extend_info_t *info; struct in_addr ip; int result, num_ok=1; + memarea_t *area = NULL; tor_assert(parsed); /** Function may only be invoked once. */ tor_assert(!parsed->intro_nodes); @@ -3516,6 +3521,7 @@ rend_decrypt_introduction_points(rend_service_descriptor_t *parsed, current_ipo = &intro_points_encrypted; tokens = smartlist_create(); parsed->intro_nodes = smartlist_create(); + area = memarea_new(4096); while (!strcmpstart(*current_ipo, "introduction-point ")) { /* Determine end of string. */ const char *eos = strstr(*current_ipo, "\nintroduction-point "); @@ -3526,8 +3532,9 @@ rend_decrypt_introduction_points(rend_service_descriptor_t *parsed, /* Free tokens and clear token list. */ SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_free(t)); smartlist_clear(tokens); + memarea_clear(area); /* Tokenize string. */ - if (tokenize_string(NULL, *current_ipo, eos, tokens, ipo_token_table, 0)) { + if (tokenize_string(area, *current_ipo, eos, tokens, ipo_token_table, 0)) { log_warn(LD_REND, "Error tokenizing introduction point."); goto err; } @@ -3594,6 +3601,8 @@ rend_decrypt_introduction_points(rend_service_descriptor_t *parsed, /* Free tokens and clear token list. */ SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_free(t)); smartlist_free(tokens); + if (area) + memarea_drop_all(area); return result; } |