From c76d00abfa779059b2936e5b84c032d0e36726d4 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 5 Sep 2018 13:37:37 -0400 Subject: hs-v3: Make hs_desc_build_fake_authorized_client() return an object Return a newly allocated fake client authorization object instead of taking the object as a parameter. Signed-off-by: David Goulet --- src/feature/hs/hs_descriptor.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/feature/hs/hs_descriptor.c') diff --git a/src/feature/hs/hs_descriptor.c b/src/feature/hs/hs_descriptor.c index 0cabe50369..9c3d4fc96b 100644 --- a/src/feature/hs/hs_descriptor.c +++ b/src/feature/hs/hs_descriptor.c @@ -2833,18 +2833,22 @@ hs_desc_intro_point_free_(hs_desc_intro_point_t *ip) tor_free(ip); } -/* Build a fake client info for the descriptor */ -void -hs_desc_build_fake_authorized_client(hs_desc_authorized_client_t *client_out) -{ - tor_assert(client_out); - - crypto_rand((char *) client_out->client_id, - sizeof(client_out->client_id)); - crypto_rand((char *) client_out->iv, - sizeof(client_out->iv)); - crypto_rand((char *) client_out->encrypted_cookie, - sizeof(client_out->encrypted_cookie)); +/* Allocate and build a new fake client info for the descriptor. Return a + * newly allocated object. This can't fail. */ +hs_desc_authorized_client_t * +hs_desc_build_fake_authorized_client(void) +{ + hs_desc_authorized_client_t *client_auth = + tor_malloc_zero(sizeof(*client_auth)); + + crypto_rand((char *) client_auth->client_id, + sizeof(client_auth->client_id)); + crypto_rand((char *) client_auth->iv, + sizeof(client_auth->iv)); + crypto_rand((char *) client_auth->encrypted_cookie, + sizeof(client_auth->encrypted_cookie)); + + return client_auth; } /* Using the client public key, auth ephemeral secret key, and descriptor -- cgit v1.2.3-54-g00ecf