aboutsummaryrefslogtreecommitdiff
path: root/src/or/shared_random.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2016-05-17 15:13:13 -0400
committerDavid Goulet <dgoulet@torproject.org>2016-07-01 14:01:41 -0400
commitcd858d78a7d04fa64b9af3d602c435154acd284f (patch)
treedb7e2b4acaa943504651ae25ec3ecf174a97010f /src/or/shared_random.c
parent63ca307127f70f2df3da20d50ecc545939658991 (diff)
downloadtor-cd858d78a7d04fa64b9af3d602c435154acd284f.tar.gz
tor-cd858d78a7d04fa64b9af3d602c435154acd284f.zip
prop250: Sort commits in lexicographical order in votes
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/shared_random.c')
-rw-r--r--src/or/shared_random.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/or/shared_random.c b/src/or/shared_random.c
index 15c33af60c..23c2b1417c 100644
--- a/src/or/shared_random.c
+++ b/src/or/shared_random.c
@@ -1205,11 +1205,21 @@ sr_get_string_for_vote(void)
/* In our vote we include every commitment in our permanent state. */
state_commits = sr_state_get_commits();
+ smartlist_t *state_commit_vote_lines = smartlist_new();
DIGESTMAP_FOREACH(state_commits, key, const sr_commit_t *, commit) {
char *line = get_vote_line_from_commit(commit, sr_state_get_phase());
- smartlist_add(chunks, line);
+ smartlist_add(state_commit_vote_lines, line);
} DIGESTMAP_FOREACH_END;
+ /* Sort the commit strings by version (string, not numeric), algorithm,
+ * and fingerprint. This makes sure the commit lines in votes are in a
+ * recognisable, stable order. */
+ smartlist_sort_strings(state_commit_vote_lines);
+
+ /* Now add the sorted list of commits to the vote */
+ smartlist_add_all(chunks, state_commit_vote_lines);
+ smartlist_free(state_commit_vote_lines);
+
/* Add the SRV value(s) if any. */
{
char *srv_lines = get_ns_str_from_sr_values(sr_state_get_previous_srv(),