diff options
author | David Goulet <dgoulet@ev0ke.net> | 2015-04-27 15:08:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-04-30 12:35:21 -0400 |
commit | 9a364026d314bfe76410318849e179dbd2e0b34d (patch) | |
tree | e4d0878e3475baf06a9ca23e7af8cda39b2c6226 /src/or/control.c | |
parent | e6a581f126bac80d1d0c61ae026d81076f03b77b (diff) | |
download | tor-9a364026d314bfe76410318849e179dbd2e0b34d.tar.gz tor-9a364026d314bfe76410318849e179dbd2e0b34d.zip |
Use rend_data_client/service_create() in code
Every callsite that use to allocate a rend_data_t object now use the
rend_data_client/service_create() function.
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 28 |
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; } |