aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendcommon.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-16 14:49:55 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-16 14:49:55 -0400
commite908e3a332dd469af2facac0846d0dc8349a30d3 (patch)
tree45195df03a09bc0fde12760ddccc60eaa59e7f72 /src/or/rendcommon.c
parent919bf6ff3cfb1387f3f9ecf9ce97d8e95e330a05 (diff)
parent4a22046c86bec7165e6977024ff84e2109832417 (diff)
downloadtor-e908e3a332dd469af2facac0846d0dc8349a30d3.tar
tor-e908e3a332dd469af2facac0846d0dc8349a30d3.tar.gz
Merge remote-tracking branch 'origin/maint-0.2.1' into maint-0.2.2
Fixed trivial conflict due to headers moving into their own .h files from or.h. Conflicts: src/or/or.h
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r--src/or/rendcommon.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index da33feccb..4d4a90f61 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -1015,9 +1015,14 @@ rend_cache_lookup_v2_desc_as_dir(const char *desc_id, const char **desc)
*
* The published flag tells us if we store the descriptor
* in our role as directory (1) or if we cache it as client (0).
+ *
+ * If <b>service_id</b> is non-NULL and the descriptor is not for that
+ * service ID, reject it. <b>service_id</b> must be specified if and
+ * only if <b>published</b> is 0 (we fetched this descriptor).
*/
int
-rend_cache_store(const char *desc, size_t desc_len, int published)
+rend_cache_store(const char *desc, size_t desc_len, int published,
+ const char *service_id)
{
rend_cache_entry_t *e;
rend_service_descriptor_t *parsed;
@@ -1035,6 +1040,12 @@ rend_cache_store(const char *desc, size_t desc_len, int published)
rend_service_descriptor_free(parsed);
return -2;
}
+ if ((service_id != NULL) && strcmp(query, service_id)) {
+ log_warn(LD_REND, "Received service descriptor for service ID %s; "
+ "expected descriptor for service ID %s.",
+ query, safe_str(service_id));
+ return -2;
+ }
now = time(NULL);
if (parsed->timestamp < now-REND_CACHE_MAX_AGE-REND_CACHE_MAX_SKEW) {
log_fn(LOG_PROTOCOL_WARN, LD_REND,
@@ -1215,6 +1226,8 @@ rend_cache_store_v2_desc_as_dir(const char *desc)
* If we have an older descriptor with the same ID, replace it.
* If we have any v0 descriptor with the same ID, reject this one in order
* to not get confused with having both versions for the same service.
+ * If the descriptor's service ID does not match
+ * <b>rend_query</b>-\>onion_address, reject it.
* Return -2 if it's malformed or otherwise rejected; return -1 if we
* already have a v0 descriptor here; return 0 if it's the same or older
* than one we've already got; return 1 if it's novel.
@@ -1265,6 +1278,13 @@ rend_cache_store_v2_desc_as_client(const char *desc,
retval = -2;
goto err;
}
+ if (strcmp(rend_query->onion_address, service_id)) {
+ log_warn(LD_REND, "Received service descriptor for service ID %s; "
+ "expected descriptor for service ID %s.",
+ service_id, safe_str(rend_query->onion_address));
+ retval = -2;
+ goto err;
+ }
/* Decode/decrypt introduction points. */
if (intro_content) {
if (rend_query->auth_type != REND_NO_AUTH &&