diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-02-05 11:50:16 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-02-05 11:53:33 -0500 |
commit | e3d4154486b278e1ee68f97c3445817759b0f73c (patch) | |
tree | 13dae3048a07bd389a7949c07caf95cab98710c5 /src/or/onion.c | |
parent | f0d7905bc9f20ecee43da3db369073ffb73b4997 (diff) | |
download | tor-e3d4154486b278e1ee68f97c3445817759b0f73c.tar.gz tor-e3d4154486b278e1ee68f97c3445817759b0f73c.zip |
Avoid a malloc/free pair for each (server-side) ntor handshake
Closes ticket 25150
Diffstat (limited to 'src/or/onion.c')
-rw-r--r-- | src/or/onion.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/or/onion.c b/src/or/onion.c index bd80c2f503..4fc5013835 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -563,20 +563,19 @@ onion_skin_server_handshake(int type, return -1; { size_t keys_tmp_len = keys_out_len + DIGEST_LEN; - uint8_t *keys_tmp = tor_malloc(keys_out_len + DIGEST_LEN); + uint8_t keys_tmp[keys_tmp_len]; if (onion_skin_ntor_server_handshake( onion_skin, keys->curve25519_key_map, keys->junk_keypair, keys->my_identity, reply_out, keys_tmp, keys_tmp_len)<0) { - tor_free(keys_tmp); + /* no need to memwipe here, since the output will never be used */ return -1; } memcpy(keys_out, keys_tmp, keys_out_len); memcpy(rend_nonce_out, keys_tmp+keys_out_len, DIGEST_LEN); memwipe(keys_tmp, 0, keys_tmp_len); - tor_free(keys_tmp); r = NTOR_REPLY_LEN; } break; |