diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-12-15 17:23:36 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-12-15 17:25:34 -0500 |
commit | fcbd65b45cbf203b00e6752dabc7bc5b8dffdbcf (patch) | |
tree | 5c27f43119bad03fc2465af47105f801bbe3dc26 /src/or/rendcommon.c | |
parent | a8190b09a319bf6b1bac7608ea77f828f9970056 (diff) | |
download | tor-fcbd65b45cbf203b00e6752dabc7bc5b8dffdbcf.tar.gz tor-fcbd65b45cbf203b00e6752dabc7bc5b8dffdbcf.zip |
Refactor the safe_str_*() API to make more sense.
The new rule is: safe_str_X() means "this string is a piece of X
information; make it safe to log." safe_str() on its own means
"this string is a piece of who-knows-what; make it safe to log".
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r-- | src/or/rendcommon.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c index 73d1b5d85d..43f9857573 100644 --- a/src/or/rendcommon.c +++ b/src/or/rendcommon.c @@ -126,7 +126,7 @@ rend_compute_v2_desc_id(char *desc_id_out, const char *service_id, strlen(service_id) != REND_SERVICE_ID_LEN_BASE32) { log_warn(LD_REND, "Could not compute v2 descriptor ID: " "Illegal service ID: %s", - safe_str_relay(service_id)); + safe_str(service_id)); return -1; } if (replica >= REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS) { @@ -139,7 +139,7 @@ rend_compute_v2_desc_id(char *desc_id_out, const char *service_id, service_id, REND_SERVICE_ID_LEN_BASE32) < 0) { log_warn(LD_REND, "Could not compute v2 descriptor ID: " "Illegal characters in service ID: %s", - safe_str(service_id)); + safe_str_client(service_id)); return -1; } /* Calculate current time-period. */ @@ -835,7 +835,7 @@ rend_cache_clean_v2_descs_as_dir(void) char key_base32[REND_DESC_ID_V2_LEN_BASE32 + 1]; base32_encode(key_base32, sizeof(key_base32), key, DIGEST_LEN); log_info(LD_REND, "Removing descriptor with ID '%s' from cache", - safe_str(key_base32)); + safe_str_client(key_base32)); iter = digestmap_iter_next_rmv(rend_cache_v2_dir, iter); _rend_cache_entry_free(ent); } else { @@ -955,7 +955,7 @@ rend_cache_lookup_v2_desc_as_dir(const char *desc_id, const char **desc) if (base32_decode(desc_id_digest, DIGEST_LEN, desc_id, REND_DESC_ID_V2_LEN_BASE32) < 0) { log_warn(LD_REND, "Descriptor ID contains illegal characters: %s", - safe_str_relay(desc_id)); + safe_str(desc_id)); return -1; } /* Determine if we are responsible. */ @@ -1012,14 +1012,14 @@ rend_cache_store(const char *desc, size_t desc_len, int published) if (parsed->timestamp < now-REND_CACHE_MAX_AGE-REND_CACHE_MAX_SKEW) { log_fn(LOG_PROTOCOL_WARN, LD_REND, "Service descriptor %s is too old.", - safe_str(query)); + safe_str_client(query)); rend_service_descriptor_free(parsed); return -2; } if (parsed->timestamp > now+REND_CACHE_MAX_SKEW) { log_fn(LOG_PROTOCOL_WARN, LD_REND, "Service descriptor %s is too far in the future.", - safe_str(query)); + safe_str_client(query)); rend_service_descriptor_free(parsed); return -2; } @@ -1027,7 +1027,7 @@ rend_cache_store(const char *desc, size_t desc_len, int published) tor_snprintf(key, sizeof(key), "2%s", query); if (!published && strmap_get_lc(rend_cache, key)) { log_info(LD_REND, "We already have a v2 descriptor for service %s.", - safe_str(query)); + safe_str_client(query)); rend_service_descriptor_free(parsed); return -1; } @@ -1040,13 +1040,13 @@ rend_cache_store(const char *desc, size_t desc_len, int published) if (e && e->parsed->timestamp > parsed->timestamp) { log_info(LD_REND,"We already have a newer service descriptor %s with the " "same ID and version.", - safe_str(query)); + safe_str_client(query)); rend_service_descriptor_free(parsed); return 0; } if (e && e->len == desc_len && !memcmp(desc,e->desc,desc_len)) { log_info(LD_REND,"We already have this service descriptor %s.", - safe_str(query)); + safe_str_client(query)); e->received = time(NULL); rend_service_descriptor_free(parsed); return 0; @@ -1069,7 +1069,7 @@ rend_cache_store(const char *desc, size_t desc_len, int published) memcpy(e->desc, desc, desc_len); log_debug(LD_REND,"Successfully stored rend desc '%s', len %d.", - safe_str(query), (int)desc_len); + safe_str_client(query), (int)desc_len); return 1; } @@ -1120,20 +1120,20 @@ rend_cache_store_v2_desc_as_dir(const char *desc) if (!hid_serv_responsible_for_desc_id(desc_id)) { log_info(LD_REND, "Service descriptor with desc ID %s is not in " "interval that we are responsible for.", - safe_str(desc_id_base32)); + safe_str_client(desc_id_base32)); goto skip; } /* Is descriptor too old? */ if (parsed->timestamp < now - REND_CACHE_MAX_AGE-REND_CACHE_MAX_SKEW) { log_info(LD_REND, "Service descriptor with desc ID %s is too old.", - safe_str_relay(desc_id_base32)); + safe_str(desc_id_base32)); goto skip; } /* Is descriptor too far in the future? */ if (parsed->timestamp > now + REND_CACHE_MAX_SKEW) { log_info(LD_REND, "Service descriptor with desc ID %s is too far in the " "future.", - safe_str_relay(desc_id_base32)); + safe_str(desc_id_base32)); goto skip; } /* Do we already have a newer descriptor? */ @@ -1141,13 +1141,13 @@ rend_cache_store_v2_desc_as_dir(const char *desc) if (e && e->parsed->timestamp > parsed->timestamp) { log_info(LD_REND, "We already have a newer service descriptor with the " "same desc ID %s and version.", - safe_str_relay(desc_id_base32)); + safe_str(desc_id_base32)); goto skip; } /* Do we already have this descriptor? */ if (e && !strcmp(desc, e->desc)) { log_info(LD_REND, "We already have this service descriptor with desc " - "ID %s.", safe_str_relay(desc_id_base32)); + "ID %s.", safe_str(desc_id_base32)); e->received = time(NULL); goto skip; } @@ -1165,7 +1165,7 @@ rend_cache_store_v2_desc_as_dir(const char *desc) e->len = encoded_size; log_info(LD_REND, "Successfully stored service descriptor with desc ID " "'%s' and len %d.", - safe_str_relay(desc_id_base32), (int)encoded_size); + safe_str(desc_id_base32), (int)encoded_size); number_stored++; goto advance; skip: @@ -1285,14 +1285,14 @@ rend_cache_store_v2_desc_as_client(const char *desc, /* Is descriptor too old? */ if (parsed->timestamp < now - REND_CACHE_MAX_AGE-REND_CACHE_MAX_SKEW) { log_warn(LD_REND, "Service descriptor with service ID %s is too old.", - safe_str(service_id)); + safe_str_client(service_id)); retval = -2; goto err; } /* Is descriptor too far in the future? */ if (parsed->timestamp > now + REND_CACHE_MAX_SKEW) { log_warn(LD_REND, "Service descriptor with service ID %s is too far in " - "the future.", safe_str(service_id)); + "the future.", safe_str_client(service_id)); retval = -2; goto err; } @@ -1300,7 +1300,7 @@ rend_cache_store_v2_desc_as_client(const char *desc, tor_snprintf(key, sizeof(key), "0%s", service_id); if (strmap_get_lc(rend_cache, key)) { log_info(LD_REND, "We already have a v0 descriptor for service ID %s.", - safe_str(service_id)); + safe_str_client(service_id)); retval = -1; goto err; } @@ -1310,14 +1310,14 @@ rend_cache_store_v2_desc_as_client(const char *desc, if (e && e->parsed->timestamp > parsed->timestamp) { log_info(LD_REND, "We already have a newer service descriptor for " "service ID %s with the same desc ID and version.", - safe_str(service_id)); + safe_str_client(service_id)); retval = 0; goto err; } /* Do we already have this descriptor? */ if (e && !strcmp(desc, e->desc)) { log_info(LD_REND,"We already have this service descriptor %s.", - safe_str(service_id)); + safe_str_client(service_id)); e->received = time(NULL); retval = 0; goto err; @@ -1335,7 +1335,7 @@ rend_cache_store_v2_desc_as_client(const char *desc, strlcpy(e->desc, desc, encoded_size + 1); e->len = encoded_size; log_debug(LD_REND,"Successfully stored rend desc '%s', len %d.", - safe_str(service_id), (int)encoded_size); + safe_str_client(service_id), (int)encoded_size); return 1; err: |