diff options
-rw-r--r-- | src/or/directory.c | 5 | ||||
-rw-r--r-- | src/or/dirvote.c | 13 | ||||
-rw-r--r-- | src/or/or.h | 3 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 66f182adcf..a60ff13236 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -35,7 +35,8 @@ static void directory_send_command(dir_connection_t *conn, const char *payload, size_t payload_len); static int directory_handle_command(dir_connection_t *conn); static int body_is_plausible(const char *body, size_t body_len, int purpose); -static int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose); +static int purpose_needs_anonymity(uint8_t dir_purpose, + uint8_t router_purpose); static char *http_get_header(const char *headers, const char *which); static void http_set_address_origin(const char *headers, connection_t *conn); static void connection_dir_download_networkstatus_failed( @@ -2112,7 +2113,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers, if (authdir_mode_v3(options) && !strcmp(url,"/tor/post/vote")) { /* server descriptor post */ const char *msg = "OK"; - if (dirserv_add_vote(body, &msg)) { + if (dirvote_add_vote(body, &msg)) { write_http_status_line(conn, 200, "Vote stored"); } else { tor_assert(msg); diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 9c1b90a2e2..06c90f80f9 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -885,8 +885,7 @@ dirvote_perform_vote(void) pending_vote_t *pending_vote; const char *msg = ""; - if ((pending_vote = dirvote_add_vote(tor_memdup(new_vote->dir, - new_vote->dir_len), &msg))) { + if ((pending_vote = dirvote_add_vote(new_vote->dir, &msg))) { log_warn(LD_DIR, "Couldn't store my own vote! (I told myself, '%s'.)", msg); return; @@ -916,7 +915,7 @@ dirvote_clear_pending_votes(void) /** DOCDOC */ pending_vote_t * -dirvote_add_vote(char *vote_body, const char **msg_out) +dirvote_add_vote(const char *vote_body, const char **msg_out) { networkstatus_vote_t *vote; networkstatus_voter_info_t *vi; @@ -952,7 +951,8 @@ dirvote_add_vote(char *vote_body, const char **msg_out) if (v->vote->published < vote->published) { cached_dir_decref(v->vote_body); networkstatus_vote_free(v->vote); - v->vote_body = new_cached_dir(vote_body, vote->published); + v->vote_body = new_cached_dir(tor_strdup(vote_body), + vote->published); v->vote = vote; *msg_out = "ok"; return v; @@ -964,14 +964,14 @@ dirvote_add_vote(char *vote_body, const char **msg_out) }); pending_vote = tor_malloc_zero(sizeof(pending_vote_t)); - pending_vote->vote_body = new_cached_dir(vote_body, vote->published); + pending_vote->vote_body = new_cached_dir(tor_strdup(vote_body), + vote->published); pending_vote->vote = vote; smartlist_add(pending_vote_list, pending_vote); *msg_out = "ok"; return pending_vote; err: - tor_free(vote_body); if (vote) networkstatus_vote_free(vote); if (!*msg_out) @@ -1020,3 +1020,4 @@ dirvote_compute_consensus(void) smartlist_free(votes); return -1; } + diff --git a/src/or/or.h b/src/or/or.h index 4af1b90f90..d60fa07037 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2812,7 +2812,8 @@ void dirvote_recalculate_timing(time_t now); /* invoked on timers and by outside triggers. */ void dirvote_perform_vote(void); void dirvote_clear_pending_votes(void); -struct pending_vote_t * dirvote_add_vote(char *vote_body,const char **msg_out); +struct pending_vote_t * dirvote_add_vote(const char *vote_body, + const char **msg_out); int dirvote_compute_consensus(void); #ifdef DIRVOTE_PRIVATE |