aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2018-04-25 11:12:56 -0400
committerDavid Goulet <dgoulet@torproject.org>2018-05-01 10:07:09 -0400
commit0f3b765b3c8ba6f4f105440861e87ecaf4ea4323 (patch)
treef7ceff711fc0fb24ca890aca06aa6c0dfa6dd3e8 /src
parentfdc01cb40e1c982c273f7e9685c586ee1ef89e30 (diff)
downloadtor-0f3b765b3c8ba6f4f105440861e87ecaf4ea4323.tar.gz
tor-0f3b765b3c8ba6f4f105440861e87ecaf4ea4323.zip
dirvote: Handling adding vote and signature if module is disabled
Both functions are used for directory request but they can only be used if the running tor instance is a directory authority. For this reason, make those symbols visible but hard assert() if they are called when the module is disabled. This would mean we failed to safeguard the entry point into the module. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src')
-rw-r--r--src/or/dirauth/dirvote.h38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/or/dirauth/dirvote.h b/src/or/dirauth/dirvote.h
index 69d628766f..59cfd6b999 100644
--- a/src/or/dirauth/dirvote.h
+++ b/src/or/dirauth/dirvote.h
@@ -104,6 +104,14 @@ void dirvote_clear_commits(networkstatus_t *ns);
void dirvote_dirreq_get_status_vote(const char *url, smartlist_t *items,
smartlist_t *dir_items);
+/* Storing signatures and votes functions */
+struct pending_vote_t * dirvote_add_vote(const char *vote_body,
+ const char **msg_out,
+ int *status_out);
+int dirvote_add_signatures(const char *detached_signatures_body,
+ const char *source,
+ const char **msg_out);
+
#else /* HAVE_MODULE_DIRAUTH */
static inline void
@@ -140,16 +148,32 @@ dirvote_dirreq_get_status_vote(const char *url, smartlist_t *items,
(void) dir_items;
}
+static inline struct pending_vote_t *
+dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out)
+{
+ (void) vote_body;
+ (void) msg_out;
+ (void) status_out;
+ /* If the dirauth module is disabled, this should NEVER be called else we
+ * failed to safeguard the dirauth module. */
+ tor_assert_nonfatal_unreached();
+}
+
+static inline int
+dirvote_add_signatures(const char *detached_signatures_body, const char *source,
+ const char **msg_out)
+{
+ (void) detached_signatures_body;
+ (void) source;
+ (void) msg_out;
+ /* If the dirauth module is disabled, this should NEVER be called else we
+ * failed to safeguard the dirauth module. */
+ tor_assert_nonfatal_unreached();
+}
+
#endif /* HAVE_MODULE_DIRAUTH */
void dirvote_recalculate_timing(const or_options_t *options, time_t now);
-/* Invoked on timers and by outside triggers. */
-struct pending_vote_t * dirvote_add_vote(const char *vote_body,
- const char **msg_out,
- int *status_out);
-int dirvote_add_signatures(const char *detached_signatures_body,
- const char *source,
- const char **msg_out);
/* Item access */
MOCK_DECL(const char*, dirvote_get_pending_consensus,
(consensus_flavor_t flav));