aboutsummaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 7c8a6c4aa7..4578f2d95e 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -3389,25 +3389,21 @@ handle_control_hsfetch(control_connection_t *conn, uint32_t len,
}
}
- rend_query = tor_malloc_zero(sizeof(*rend_query));
-
- if (hsaddress) {
- strncpy(rend_query->onion_address, hsaddress,
- sizeof(rend_query->onion_address));
- } else if (desc_id) {
- /* Using a descriptor ID, we force the user to provide at least one
- * hsdir server using the SERVER= option. */
- if (!hsdirs || !smartlist_len(hsdirs)) {
+ rend_query = rend_data_client_create(hsaddress, desc_id, NULL,
+ REND_NO_AUTH);
+ if (rend_query == NULL) {
+ connection_printf_to_buf(conn, "551 Error creating the HS query\r\n");
+ goto done;
+ }
+
+ /* Using a descriptor ID, we force the user to provide at least one
+ * hsdir server using the SERVER= option. */
+ if (desc_id && (!hsdirs || !smartlist_len(hsdirs))) {
connection_printf_to_buf(conn, "512 %s option is required\r\n",
opt_server);
goto done;
- }
- memcpy(rend_query->descriptor_id, desc_id,
- sizeof(rend_query->descriptor_id));
- } else {
- /* We can't get in here because of the first argument check. */
- tor_assert(0);
}
+
/* We are about to trigger HSDir fetch so send the OK now because after
* that 650 event(s) are possible so better to have the 250 OK before them
* to avoid out of order replies. */
@@ -3423,7 +3419,7 @@ done:
smartlist_free(args);
/* Contains data pointer that we don't own thus no cleanup. */
smartlist_free(hsdirs);
- tor_free(rend_query);
+ rend_data_free(rend_query);
exit:
return 0;
}