diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-03-05 09:50:26 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-03-05 09:50:26 +0000 |
commit | 5777ee0e1a8bf0652aff75bb2c316c5bbbb4b854 (patch) | |
tree | e410cb36f9345a0aa46b735ca2128da55a68c152 /src/or/routerparse.c | |
parent | 6a4e304d9e613b613e208bb0f11ec44c3fc30150 (diff) | |
download | tor-5777ee0e1a8bf0652aff75bb2c316c5bbbb4b854.tar.gz tor-5777ee0e1a8bf0652aff75bb2c316c5bbbb4b854.zip |
Add some functions to escape values from the network before sending them to the log. Use them everywhere except for routerinfo->plaftorm, routerinfo->contact_info, and rend*.c. (need sleep now)
svn:r6087
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r-- | src/or/routerparse.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index c5df489f35..b4ad4cfef0 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -468,8 +468,8 @@ router_parse_runningrouters(const char *str) log_warn(LD_DIR, "Error tokenizing directory"); goto err; } if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) { - log_warn(LD_DIR, "Unrecognized keyword '%s'; can't parse running-routers", - tok->args[0]); + log_warn(LD_DIR, "Unrecognized keyword %s; can't parse running-routers", + escaped(tok->args[0])); goto err; } tok = smartlist_get(tokens,0); @@ -736,9 +736,9 @@ router_parse_entry_from_string(const char *s, const char *end) } if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) { log_warn(LD_DIR, - "Unrecognized critical keyword '%s'; skipping descriptor. " + "Unrecognized critical keyword %s; skipping descriptor. " "(It may be from another version of Tor.)", - tok->args[0]); + escaped(tok->args[0])); goto err; } @@ -852,7 +852,8 @@ router_parse_entry_from_string(const char *s, const char *end) } tor_strstrip(tok->args[0], " "); if (base16_decode(d, DIGEST_LEN, tok->args[0], strlen(tok->args[0]))) { - log_warn(LD_DIR, "Couldn't decode fingerprint '%s'", tok->args[0]); + log_warn(LD_DIR, "Couldn't decode fingerprint %s", + escaped(tok->args[0])); goto err; } if (memcmp(d,router->cache_info.identity_digest, DIGEST_LEN)!=0) { @@ -882,7 +883,8 @@ router_parse_entry_from_string(const char *s, const char *end) router->declared_family = smartlist_create(); for (i=0;i<tok->n_args;++i) { if (!is_legal_nickname_or_hexdigest(tok->args[i])) { - log_warn(LD_DIR, "Illegal nickname '%s' in family line", tok->args[i]); + log_warn(LD_DIR, "Illegal nickname %s in family line", + escaped(tok->args[i])); goto err; } smartlist_add(router->declared_family, tor_strdup(tok->args[i])); @@ -977,8 +979,8 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens) goto err; } if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) { - log_warn(LD_DIR, "Unrecognized keyword \"%s\" in router status; skipping.", - tok->args[0]); + log_warn(LD_DIR, "Unrecognized keyword %s in router status; skipping.", + escaped(tok->args[0])); goto err; } if (!(tok = find_first_by_keyword(tokens, K_R))) { @@ -993,19 +995,19 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens) if (!is_legal_nickname(tok->args[0])) { log_warn(LD_DIR, - "Invalid nickname '%s' in router status; skipping.", - tok->args[0]); + "Invalid nickname %s in router status; skipping.", + escaped(tok->args[0])); goto err; } strlcpy(rs->nickname, tok->args[0], sizeof(rs->nickname)); if (digest_from_base64(rs->identity_digest, tok->args[1])) { - log_warn(LD_DIR, "Error decoding digest '%s'", tok->args[1]); + log_warn(LD_DIR, "Error decoding digest %s", escaped(tok->args[1])); goto err; } if (digest_from_base64(rs->descriptor_digest, tok->args[2])) { - log_warn(LD_DIR, "Error decoding digest '%s'", tok->args[2]); + log_warn(LD_DIR, "Error decoding digest %s", escaped(tok->args[2])); goto err; } @@ -1018,7 +1020,7 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens) } if (tor_inet_aton(tok->args[5], &in) == 0) { - log_warn(LD_DIR, "Error parsing address '%s'", tok->args[5]); + log_warn(LD_DIR, "Error parsing address '%s'", escaped(tok->args[5])); goto err; } rs->addr = ntohl(in.s_addr); @@ -1097,8 +1099,8 @@ networkstatus_parse_from_string(const char *s) goto err; } if ((tok = find_first_by_keyword(tokens, _UNRECOGNIZED))) { - log_warn(LD_DIR, "Unrecognized keyword '%s'; can't parse network-status", - tok->args[0]); + log_warn(LD_DIR, "Unrecognized keyword %s; can't parse network-status", + escaped(tok->args[0])); goto err; } ns = tor_malloc_zero(sizeof(networkstatus_t)); @@ -1119,7 +1121,7 @@ networkstatus_parse_from_string(const char *s) } ns->source_address = tok->args[0]; tok->args[0] = NULL; if (tor_inet_aton(tok->args[1], &in) == 0) { - log_warn(LD_DIR, "Error parsing address '%s'", tok->args[1]); + log_warn(LD_DIR, "Error parsing address %s", escaped(tok->args[1])); goto err; } ns->source_addr = ntohl(in.s_addr); @@ -1140,7 +1142,7 @@ networkstatus_parse_from_string(const char *s) } if (base16_decode(ns->identity_digest, DIGEST_LEN, tok->args[0], strlen(tok->args[0]))) { - log_warn(LD_DIR, "Couldn't decode fingerprint '%s'", tok->args[0]); + log_warn(LD_DIR, "Couldn't decode fingerprint %s", escaped(tok->args[0])); goto err; } @@ -1369,7 +1371,7 @@ router_parse_addr_policy(directory_token_t *tok) policy_read_failed: tor_assert(newe->string); - log_warn(LD_DIR,"Couldn't parse line '%s'. Dropping", newe->string); + log_warn(LD_DIR,"Couldn't parse line %s. Dropping", escaped(newe->string)); tor_free(newe->string); tor_free(newe); return NULL; |