From 2503cfad240bfd59b033b4380b0ebd4a8a148802 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 31 Jul 2012 10:48:35 -0400 Subject: Allow microdescs to be up to 2k. Partial fix for 6404. --- src/or/dirvote.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/or/dirvote.c') diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 79958739a5..85ea85ce73 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -3502,7 +3502,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) { microdesc_t *result = NULL; char *key = NULL, *summary = NULL, *family = NULL; - char buf[1024]; + char buf[2048]; size_t keylen; char *out = buf, *end = buf+sizeof(buf); -- cgit v1.2.3-54-g00ecf From 7143d112a69806bde4a29bf8da94704cfb435fe3 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 31 Jul 2012 10:54:14 -0400 Subject: Don't include a router in an md consensus if we can't find a md for it. The spec requires that every router in a microdesc consensus have an m line; we weren't obeying that spec. This creates a new consensus method (13) to allow voting to continue to work right. Partial fix for bug 6404; fix on 0.2.2.6-alpha. --- changes/bug6404 | 5 +++++ src/or/dirvote.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src/or/dirvote.c') diff --git a/changes/bug6404 b/changes/bug6404 index d01964d1e5..64d459418f 100644 --- a/changes/bug6404 +++ b/changes/bug6404 @@ -5,3 +5,8 @@ with complex policies or family declarations. Partial fix for bug 6404; fix on 0.2.2.6-alpha. + - Authorities no longer include any router in their + microdescriptor consensuses for which they couldn't generate or + agree on a microdescriptor. Partial fix for bug 6404; fix on + 0.2.2.6-alpha. + diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 85ea85ce73..87af5becf7 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -54,7 +54,7 @@ static int dirvote_publish_consensus(void); static char *make_consensus_method_list(int low, int high, const char *sep); /** The highest consensus method that we currently support. */ -#define MAX_SUPPORTED_CONSENSUS_METHOD 12 +#define MAX_SUPPORTED_CONSENSUS_METHOD 13 /** Lowest consensus method that contains a 'directory-footer' marker */ #define MIN_METHOD_FOR_FOOTER 9 @@ -72,6 +72,10 @@ static char *make_consensus_method_list(int low, int high, const char *sep); * for a param. */ #define MIN_METHOD_FOR_MAJORITY_PARAMS 12 +/** Lowest consensus method where microdesc consensuses omit any entry + * with no microdesc. */ +#define MIN_METHOD_FOR_MANDATORY_MICRODESC 13 + /* ===== * Voting * =====*/ @@ -1935,6 +1939,13 @@ networkstatus_compute_consensus(smartlist_t *votes, } } + if (flavor == FLAV_MICRODESC && + consensus_method >= MIN_METHOD_FOR_MANDATORY_MICRODESC && + tor_digest256_is_zero(microdesc_digest)) { + /* With no microdescriptor digest, we omit the entry entirely. */ + continue; + } + { char buf[4096]; /* Okay!! Now we can write the descriptor... */ -- cgit v1.2.3-54-g00ecf From d3e1e458e11715a9fea2fea2cb228ff925c72851 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 31 Jul 2012 13:12:07 -0400 Subject: Remove the upper limit on the size of MD we can generate. --- src/or/dirvote.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/or/dirvote.c') diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 87af5becf7..dc1ba7e8c4 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -3513,9 +3513,9 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) { microdesc_t *result = NULL; char *key = NULL, *summary = NULL, *family = NULL; - char buf[2048]; size_t keylen; - char *out = buf, *end = buf+sizeof(buf); + smartlist_t *chunks = smartlist_new(); + char *output; if (crypto_pk_write_public_key_to_string(ri->onion_pkey, &key, &keylen)<0) goto done; @@ -3523,23 +3523,19 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) if (ri->declared_family) family = smartlist_join_strings(ri->declared_family, " ", 0, NULL); - if (tor_snprintf(out, end-out, "onion-key\n%s", key)<0) - goto done; - out += strlen(out); - if (family) { - if (tor_snprintf(out, end-out, "family %s\n", family)<0) - goto done; - out += strlen(out); - } - if (summary && strcmp(summary, "reject 1-65535")) { - if (tor_snprintf(out, end-out, "p %s\n", summary)<0) - goto done; - out += strlen(out); - } - *out = '\0'; /* Make sure it's nul-terminated. This should be a no-op */ + smartlist_add_asprintf(chunks, "onion-key\n%s", key); + + if (family) + smartlist_add_asprintf(chunks, "family %s\n", family); + + if (summary && strcmp(summary, "reject 1-65535")) + smartlist_add_asprintf(chunks, "p %s\n", summary); + + output = smartlist_join_strings(chunks, "", 0, NULL); { - smartlist_t *lst = microdescs_parse_from_string(buf, out, 0, 1); + smartlist_t *lst = microdescs_parse_from_string(output, + output+strlen(output), 0, 1); if (smartlist_len(lst) != 1) { log_warn(LD_DIR, "We generated a microdescriptor we couldn't parse."); SMARTLIST_FOREACH(lst, microdesc_t *, md, microdesc_free(md)); @@ -3554,6 +3550,10 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) tor_free(key); tor_free(summary); tor_free(family); + if (chunks) { + SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp)); + smartlist_free(chunks); + } return result; } -- cgit v1.2.3-54-g00ecf From a9eed33111173d9f7c7fbff74ab1573c4c12e634 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 14 Aug 2012 03:06:47 -0400 Subject: Fix memory leak in dirvote_create_microdescriptor Found by George, who gets a cookie. --- src/or/dirvote.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/or/dirvote.c') diff --git a/src/or/dirvote.c b/src/or/dirvote.c index dc1ba7e8c4..a7fea0a75e 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -3515,7 +3515,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) char *key = NULL, *summary = NULL, *family = NULL; size_t keylen; smartlist_t *chunks = smartlist_new(); - char *output; + char *output = NULL; if (crypto_pk_write_public_key_to_string(ri->onion_pkey, &key, &keylen)<0) goto done; @@ -3547,6 +3547,7 @@ dirvote_create_microdescriptor(const routerinfo_t *ri) } done: + tor_free(output); tor_free(key); tor_free(summary); tor_free(family); -- cgit v1.2.3-54-g00ecf