[tor-commits] [tor/master] Do more type checking when setting HS idents.

nickm at torproject.org nickm at torproject.org
Wed Aug 9 00:36:38 UTC 2017


commit 0bf8587858b927d1dcb39189442f55d8dabe50aa
Author: George Kadianakis <desnacked at riseup.net>
Date:   Sat Aug 5 00:33:34 2017 +0300

    Do more type checking when setting HS idents.
    
    I repurposed the old directory_request_set_hs_ident() into a new
    directory_request_upload_set_hs_ident() which is only used for the
    upload purpose and so it can assert on the dir_purpose.
    
    When coding the client-side we can make a second function for fetch.
---
 src/or/directory.c  | 7 +++----
 src/or/directory.h  | 4 ++--
 src/or/hs_service.c | 2 +-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index fc83c013c..e079a5941 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1281,12 +1281,11 @@ directory_request_set_rend_query(directory_request_t *req,
  * <b>ident</b> object must outlive the request.
  */
 void
-directory_request_set_hs_ident(directory_request_t *req,
-                               const hs_ident_dir_conn_t *ident)
+directory_request_upload_set_hs_ident(directory_request_t *req,
+                                      const hs_ident_dir_conn_t *ident)
 {
   if (ident) {
-    tor_assert(req->dir_purpose == DIR_PURPOSE_FETCH_HSDESC ||
-               req->dir_purpose == DIR_PURPOSE_UPLOAD_HSDESC);
+    tor_assert(req->dir_purpose == DIR_PURPOSE_UPLOAD_HSDESC);
   }
   req->hs_ident = ident;
 }
diff --git a/src/or/directory.h b/src/or/directory.h
index 6b3102bc3..d3f8a45a8 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -73,8 +73,8 @@ void directory_request_set_if_modified_since(directory_request_t *req,
                                              time_t if_modified_since);
 void directory_request_set_rend_query(directory_request_t *req,
                                       const rend_data_t *query);
-void directory_request_set_hs_ident(directory_request_t *req,
-                                    const hs_ident_dir_conn_t *ident);
+void directory_request_upload_set_hs_ident(directory_request_t *req,
+                                           const hs_ident_dir_conn_t *ident);
 
 void directory_request_set_routerstatus(directory_request_t *req,
                                         const routerstatus_t *rs);
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index bea760837..43528a428 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -1957,7 +1957,7 @@ upload_descriptor_to_hsdir(const hs_service_t *service,
                                 strlen(encoded_desc));
   /* The ident object is copied over the directory connection object once
    * the directory request is initiated. */
-  directory_request_set_hs_ident(dir_req, &ident);
+  directory_request_upload_set_hs_ident(dir_req, &ident);
 
   /* Initiate the directory request to the hsdir.*/
   directory_initiate_request(dir_req);





More information about the tor-commits mailing list