summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-02-15 20:40:03 -0500
committerNick Mathewson <nickm@torproject.org>2018-02-15 20:40:03 -0500
commited1d630f0e3d2d733989eefe9fce5c287a7ca6c9 (patch)
treebc1d8f2fda75cc6560a243a6c872c2340b076cdc
parent28c3f538e50af1b4a10e613856841ea8ca41bc33 (diff)
parente3d4154486b278e1ee68f97c3445817759b0f73c (diff)
downloadtor-ed1d630f0e3d2d733989eefe9fce5c287a7ca6c9.tar.gz
tor-ed1d630f0e3d2d733989eefe9fce5c287a7ca6c9.zip
Merge branch 'onion_ntor_malloc_less'
-rw-r--r--changes/feature251504
-rw-r--r--src/or/onion.c5
2 files changed, 6 insertions, 3 deletions
diff --git a/changes/feature25150 b/changes/feature25150
new file mode 100644
index 0000000000..eb65327a8d
--- /dev/null
+++ b/changes/feature25150
@@ -0,0 +1,4 @@
+ o Minor features (performance, allocation):
+ - Avoid a needless malloc()/free() pair every time we handle an ntor
+ handshake. Closes ticket 25150.
+
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;