[tor-commits] [tor/master] vote: Return error when adding vote/signature if no dirauth module

nickm at torproject.org nickm at torproject.org
Tue May 1 14:32:50 UTC 2018


commit d8509b450a1de815399a42b5df8c6b25789429c7
Author: David Goulet <dgoulet at torproject.org>
Date:   Tue May 1 10:15:28 2018 -0400

    vote: Return error when adding vote/signature if no dirauth module
    
    Commit 0f3b765b3c8ba6f4f105440861e87ecaf4ea4323 added
    tor_assert_nonfatal_unreached() to dirvote_add_vote() and
    dirvote_add_signatures() when the dirauth module is disabled.
    
    However, they need to return a value. Furthermore, the dirvote_add_vote()
    needs to set the msg_out and status_out so it can be sent back. Else,
    uninitialized values would be used.
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 src/or/dirauth/dirvote.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/or/dirauth/dirvote.h b/src/or/dirauth/dirvote.h
index 2c3b1a1cf..f69e872c8 100644
--- a/src/or/dirauth/dirvote.h
+++ b/src/or/dirauth/dirvote.h
@@ -152,11 +152,14 @@ 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();
+
+  /* We need to send out an error code. */
+  *status_out = 400;
+  *msg_out = "No directory authority support";
+  return NULL;
 }
 
 static inline int
@@ -169,6 +172,7 @@ dirvote_add_signatures(const char *detached_signatures_body, const char *source,
   /* If the dirauth module is disabled, this should NEVER be called else we
    * failed to safeguard the dirauth module. */
   tor_assert_nonfatal_unreached();
+  return 0;
 }
 
 #endif /* HAVE_MODULE_DIRAUTH */





More information about the tor-commits mailing list