aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-07-31 13:12:07 -0400
committerNick Mathewson <nickm@torproject.org>2012-07-31 13:12:07 -0400
commitd3e1e458e11715a9fea2fea2cb228ff925c72851 (patch)
tree6c06fa0fe179b757e1ef08a3890be5a33471d1d6 /src/or
parent063138e001d3608b1e8b6619661d906cfea74ae0 (diff)
downloadtor-d3e1e458e11715a9fea2fea2cb228ff925c72851.tar
tor-d3e1e458e11715a9fea2fea2cb228ff925c72851.tar.gz
Remove the upper limit on the size of MD we can generate.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/dirvote.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 87af5becf..dc1ba7e8c 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;
}