diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-03 16:36:15 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-03 16:36:15 +0000 |
commit | 73c6cb8353355d5895b67252ac28489428263875 (patch) | |
tree | c96f4762c6ede18ff7ebac50cfd415d77335940a /src/or/routerparse.c | |
parent | 3f84ed3d46f52e3a147dfd205d3e76aa27254cf8 (diff) | |
download | tor-73c6cb8353355d5895b67252ac28489428263875.tar.gz tor-73c6cb8353355d5895b67252ac28489428263875.zip |
Fix unit test failure related to intro point parsing.
svn:r17188
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r-- | src/or/routerparse.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index c6b7454966..d093b72220 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -3671,7 +3671,7 @@ rend_decrypt_introduction_points(char **ipos_decrypted, crypto_free_cipher_env(cipher); cipher = crypto_create_init_cipher(session_key, 0); len = ipos_encrypted_size - 2 - client_entries_len - CIPHER_IV_LEN; - dec = tor_malloc_zero(len); + dec = tor_malloc(len); declen = crypto_cipher_decrypt_with_iv(cipher, dec, len, ipos_encrypted + 2 + client_entries_len, ipos_encrypted_size - 2 - client_entries_len); @@ -3681,7 +3681,7 @@ rend_decrypt_introduction_points(char **ipos_decrypted, tor_free(dec); return -1; } - if (strcmpstart(dec, "introduction-point ")) { + if (memcmpstart(dec, declen, "introduction-point ")) { log_warn(LD_REND, "Decrypted introduction points don't " "look like we could parse them."); tor_free(dec); @@ -3731,7 +3731,7 @@ rend_parse_introduction_points(rend_service_descriptor_t *parsed, const char *intro_points_encoded, size_t intro_points_encoded_size) { - const char **current_ipo; + const char *current_ipo, *end_of_intro_points; smartlist_t *tokens; directory_token_t *tok; rend_intro_point_t *intro; @@ -3744,28 +3744,33 @@ rend_parse_introduction_points(rend_service_descriptor_t *parsed, tor_assert(intro_points_encoded); tor_assert(intro_points_encoded_size > 0); /* Consider one intro point after the other. */ - current_ipo = &intro_points_encoded; + current_ipo = intro_points_encoded; + end_of_intro_points = intro_points_encoded + intro_points_encoded_size; tokens = smartlist_create(); parsed->intro_nodes = smartlist_create(); area = memarea_new(4096); - while (!strcmpstart(*current_ipo, "introduction-point ")) { + + while (!memcmpstart(current_ipo, end_of_intro_points-current_ipo, + "introduction-point ")) { /* Determine end of string. */ - const char *eos = strstr(*current_ipo, "\nintroduction-point "); + const char *eos = tor_memstr(current_ipo, end_of_intro_points-current_ipo, + "\nintroduction-point "); if (!eos) - eos = *current_ipo+strlen(*current_ipo); + eos = end_of_intro_points; else eos = eos+1; + tor_assert(eos <= intro_points_encoded+intro_points_encoded_size); /* 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(area, *current_ipo, eos, tokens, ipo_token_table, 0)) { - log_warn(LD_REND, "Error tokenizing introduction point."); + if (tokenize_string(area, current_ipo, eos, tokens, ipo_token_table, 0)) { + log_warn(LD_REND, "Error tokenizing introduction point"); goto err; } /* Advance to next introduction point, if available. */ - *current_ipo = eos; + current_ipo = eos; /* Check minimum allowed length of introduction point. */ if (smartlist_len(tokens) < 5) { log_warn(LD_REND, "Impossibly short introduction point."); |