diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-02-20 00:55:34 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-04-18 11:04:56 -0400 |
commit | 9246a7ca58d14a975b2788772238c5a7799d54b6 (patch) | |
tree | 90ef397fae2590351a28f14bd18cce311a7dfdd1 /src/or/dirvote.c | |
parent | 9f044eac77ee2245de71283e71361346ee194f25 (diff) | |
download | tor-9246a7ca58d14a975b2788772238c5a7799d54b6.tar.gz tor-9246a7ca58d14a975b2788772238c5a7799d54b6.zip |
Refactor routerstatus_format_entry to avoid character-buffers
Diffstat (limited to 'src/or/dirvote.c')
-rw-r--r-- | src/or/dirvote.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c index bd4e2f69ae..a7876701af 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -171,15 +171,12 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key, SMARTLIST_FOREACH_BEGIN(v3_ns->routerstatus_list, vote_routerstatus_t *, vrs) { -#define MAX_VOTE_ROUTERSTATUS_LEN 8192 - char rs_buf[MAX_VOTE_ROUTERSTATUS_LEN]; + char *rsf; vote_microdesc_hash_t *h; - if (routerstatus_format_entry(rs_buf, sizeof(rs_buf), &vrs->status, - vrs->version, NS_V3_VOTE, vrs) < 0) { - log_warn(LD_BUG, "Unable to print router status; skipping"); - continue; - } - smartlist_add(chunks, tor_strdup(rs_buf)); + rsf = routerstatus_format_entry(&vrs->status, + vrs->version, NS_V3_VOTE, vrs); + if (rsf) + smartlist_add(chunks, rsf); for (h = vrs->microdesc; h; h = h->next) { smartlist_add(chunks, tor_strdup(h->microdesc_hash_line)); @@ -1982,12 +1979,12 @@ networkstatus_compute_consensus(smartlist_t *votes, } { - char buf[4096]; + char *buf; /* Okay!! Now we can write the descriptor... */ /* First line goes into "buf". */ - routerstatus_format_entry(buf, sizeof(buf), &rs_out, NULL, - rs_format, NULL); - smartlist_add(chunks, tor_strdup(buf)); + buf = routerstatus_format_entry(&rs_out, NULL, rs_format, NULL); + if (buf) + smartlist_add(chunks, buf); } /* Now an m line, if applicable. */ if (flavor == FLAV_MICRODESC && |