]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
hs-v3: fix use after free in client auth config
authorSuphanat Chunhapanya <haxx.pop@gmail.com>
Tue, 15 Jan 2019 05:12:31 +0000 (12:12 +0700)
committerSuphanat Chunhapanya <haxx.pop@gmail.com>
Wed, 23 Jan 2019 21:31:07 +0000 (04:31 +0700)
We accidentally use `auth` after freeing it in
client_service_authorization_free. The way to solve it is to
free after using it.

src/feature/hs/hs_client.c

index 5fded92fe380b92245ac70bc3e034f8f18f34479..e04f0cc0c3e314175054a1801eaf3d65a8889226 100644 (file)
@@ -1637,17 +1637,17 @@ hs_config_client_authorization(const or_options_t *options,
        * as a key of global map in the future. */
       if (hs_parse_address(auth->onion_address, &identity_pk,
                            NULL, NULL) < 0) {
-        client_service_authorization_free(auth);
         log_warn(LD_REND, "The onion address \"%s\" is invalid in "
                           "file %s", filename, auth->onion_address);
+        client_service_authorization_free(auth);
         continue;
       }
 
       if (digest256map_get(auths, identity_pk.pubkey)) {
-        client_service_authorization_free(auth);
         log_warn(LD_REND, "Duplicate authorization for the same hidden "
                           "service address %s.",
                  safe_str_client(auth->onion_address));
+        client_service_authorization_free(auth);
         goto end;
       }