diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-11-30 12:07:59 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-11-30 12:07:59 -0500 |
commit | ba4a9cf0c094b7a19e1bf44264b1244a23a4b38e (patch) | |
tree | bab81ffaf9bf664f4d699db1c99a67636c445032 /src | |
parent | 3030741b5d24e9ae36e6d72c6a8c7d035fde9d2a (diff) | |
parent | f49876d66efbc5679ba7d9d9c6538c763b8e06b5 (diff) | |
download | tor-ba4a9cf0c094b7a19e1bf44264b1244a23a4b38e.tar.gz tor-ba4a9cf0c094b7a19e1bf44264b1244a23a4b38e.zip |
Merge branch 'maint-0.2.5' into maint-0.2.8
Diffstat (limited to 'src')
-rw-r--r-- | src/common/crypto.c | 16 | ||||
-rw-r--r-- | src/or/rendservice.c | 4 | ||||
-rw-r--r-- | src/or/routerlist.c | 5 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index f7bb8ff1f9..2f7e053c89 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -666,11 +666,21 @@ MOCK_IMPL(int, return 0; } +/** A PEM callback that always reports a failure to get a password */ +static int +pem_no_password_cb(char *buf, int size, int rwflag, void *u) +{ + (void)buf; + (void)size; + (void)rwflag; + (void)u; + return 0; +} + /** Read a PEM-encoded private key from the <b>len</b>-byte string <b>s</b> * into <b>env</b>. Return 0 on success, -1 on failure. If len is -1, * the string is nul-terminated. */ -/* Used here, and used for testing. */ int crypto_pk_read_private_key_from_string(crypto_pk_t *env, const char *s, ssize_t len) @@ -689,7 +699,7 @@ crypto_pk_read_private_key_from_string(crypto_pk_t *env, if (env->key) RSA_free(env->key); - env->key = PEM_read_bio_RSAPrivateKey(b,NULL,NULL,NULL); + env->key = PEM_read_bio_RSAPrivateKey(b,NULL,pem_no_password_cb,NULL); BIO_free(b); @@ -821,7 +831,7 @@ crypto_pk_read_public_key_from_string(crypto_pk_t *env, const char *src, if (env->key) RSA_free(env->key); - env->key = PEM_read_bio_RSAPublicKey(b, NULL, NULL, NULL); + env->key = PEM_read_bio_RSAPublicKey(b, NULL, pem_no_password_cb, NULL); BIO_free(b); if (!env->key) { crypto_log_errors(LOG_WARN, "reading public key from string"); diff --git a/src/or/rendservice.c b/src/or/rendservice.c index cbf9981360..829a1b7aea 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -1469,6 +1469,7 @@ rend_service_receive_introduction(origin_circuit_t *circuit, time_t now = time(NULL); time_t elapsed; int replay; + size_t keylen; /* Do some initial validation and logging before we parse the cell */ if (circuit->base_.purpose != CIRCUIT_PURPOSE_S_INTRO) { @@ -1544,9 +1545,10 @@ rend_service_receive_introduction(origin_circuit_t *circuit, } /* check for replay of PK-encrypted portion. */ + keylen = crypto_pk_keysize(intro_key); replay = replaycache_add_test_and_elapsed( intro_point->accepted_intro_rsa_parts, - parsed_req->ciphertext, parsed_req->ciphertext_len, + parsed_req->ciphertext, MIN(parsed_req->ciphertext_len, keylen), &elapsed); if (replay) { diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 64baf4d709..0c7c5e98f1 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -2536,7 +2536,10 @@ router_choose_random_node(smartlist_t *excludedsmartlist, }); } - if ((r = routerlist_find_my_routerinfo())) + /* If the node_t is not found we won't be to exclude ourself but we + * won't be able to pick ourself in router_choose_random_node() so + * this is fine to at least try with our routerinfo_t object. */ + if ((r = router_get_my_routerinfo())) routerlist_add_node_and_family(excludednodes, r); router_add_running_nodes_to_smartlist(sl, allow_invalid, |