]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs-v3: Build onion address before registering ephemeral service
authorDavid Goulet <dgoulet@torproject.org>
Wed, 23 May 2018 15:49:02 +0000 (11:49 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 2 Jun 2018 17:33:20 +0000 (10:33 -0700)
With the work on #25500 (reducing CPU client usage), the HS service main loop
callback is enabled as soon as the HS service map changes which happens when
registering a new service.

Unfortunately, for an ephemeral service, we were building the onion address
*after* the registration leading to the "service->onion_address` to be an
empty string.

This broke the "HS_DESC CREATED" event which had no onion address in it. And
also, we were logging an empty onion address for that service.

Fixes #25939

Signed-off-by: David Goulet <dgoulet@torproject.org>
changes/bug25939 [new file with mode: 0644]
src/or/hs_service.c

diff --git a/changes/bug25939 b/changes/bug25939
new file mode 100644 (file)
index 0000000..a11c73a
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor bugfixes (onion services):
+    - Fix a bug that blocked the creation of ephemeral v3 onion services. Fixes
+      bug 25939; bugfix on 0.3.4.1-alpha.
index 9001a521aba8ba29257021291836b729e5b00a4d..f1f26954aee07821b7b8a0d92a99cdf410d6c6f0 100644 (file)
@@ -3062,6 +3062,12 @@ hs_service_add_ephemeral(ed25519_secret_key_t *sk, smartlist_t *ports,
     goto err;
   }
 
+  /* Build the onion address for logging purposes but also the control port
+   * uses it for the HS_DESC event. */
+  hs_build_address(&service->keys.identity_pk,
+                   (uint8_t) service->config.version,
+                   service->onion_address);
+
   /* The only way the registration can fail is if the service public key
    * already exists. */
   if (BUG(register_service(hs_service_map, service) < 0)) {
@@ -3071,14 +3077,10 @@ hs_service_add_ephemeral(ed25519_secret_key_t *sk, smartlist_t *ports,
     goto err;
   }
 
-  /* Last step is to build the onion address. */
-  hs_build_address(&service->keys.identity_pk,
-                   (uint8_t) service->config.version,
-                   service->onion_address);
-  *address_out = tor_strdup(service->onion_address);
-
   log_info(LD_CONFIG, "Added ephemeral v3 onion service: %s",
            safe_str_client(service->onion_address));
+
+  *address_out = tor_strdup(service->onion_address);
   ret = RSAE_OKAY;
   goto end;