diff options
author | David Goulet <dgoulet@torproject.org> | 2017-09-11 13:16:23 -0400 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2017-09-12 01:32:04 +0300 |
commit | 7150214baf2385d0e64fd11fe4138932675d444f (patch) | |
tree | 3379659d49978f1b43f6a54f4d69e752a4378f4b /src/or/hs_ident.c | |
parent | 67a5d4cb60a9f27e981b83195cf47183a7e9abcc (diff) | |
download | tor-7150214baf2385d0e64fd11fe4138932675d444f.tar.gz tor-7150214baf2385d0e64fd11fe4138932675d444f.zip |
hs-v3: Cancel active descriptor directory connections before uploading
It is possible that two descriptor upload requests are launched in a very
short time frame which can lead to the second request finishing before the
first one and where that first one will make the HSDir send back a 400
malformed descriptor leading to a warning.
To avoid such, cancel all active directory connections for the specific
descriptor we are about to upload.
Note that this race is still possible on the HSDir side which triggers a log
info to be printed out but that is fine.
Fixes #23457
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_ident.c')
-rw-r--r-- | src/or/hs_ident.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/or/hs_ident.c b/src/or/hs_ident.c index df39285158..b0e4e36a9b 100644 --- a/src/or/hs_ident.c +++ b/src/or/hs_ident.c @@ -65,6 +65,22 @@ hs_ident_dir_conn_free(hs_ident_dir_conn_t *ident) tor_free(ident); } +/* Initialized the allocated ident object with identity_pk and blinded_pk. + * None of them can be NULL since a valid directory connection identifier must + * have all fields set. */ +void +hs_ident_dir_conn_init(const ed25519_public_key_t *identity_pk, + const ed25519_public_key_t *blinded_pk, + hs_ident_dir_conn_t *ident) +{ + tor_assert(identity_pk); + tor_assert(blinded_pk); + tor_assert(ident); + + ed25519_pubkey_copy(&ident->identity_pk, identity_pk); + ed25519_pubkey_copy(&ident->blinded_pk, blinded_pk); +} + /* Return a newly allocated edge connection identifier. The given public key * identity_pk is copied into the identifier. */ hs_ident_edge_conn_t * |