[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [tor/release-0.2.2] Handle failing cases of DH allocation



commit 76582442a8baefe1b469f86d35ce2d00f01a00ca
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Tue Jan 25 18:09:38 2011 -0500

    Handle failing cases of DH allocation
---
 src/common/tortls.c |    1 +
 src/or/onion.c      |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/common/tortls.c b/src/common/tortls.c
index 8ad0f2f..10f4440 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -808,6 +808,7 @@ tor_tls_context_new(crypto_pk_env_t *identity, unsigned int key_lifetime)
     goto error;
   {
     crypto_dh_env_t *dh = crypto_dh_new(DH_TYPE_TLS);
+    tor_assert(dh);
     SSL_CTX_set_tmp_dh(result->ctx, _crypto_dh_env_get_dh(dh));
     crypto_dh_free(dh);
   }
diff --git a/src/or/onion.c b/src/or/onion.c
index 9aa16d2..e1d10a6 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -259,6 +259,10 @@ onion_skin_server_handshake(const char *onion_skin, /*ONIONSKIN_CHALLENGE_LEN*/
   }
 
   dh = crypto_dh_new(DH_TYPE_CIRCUIT);
+  if (!dh) {
+    log_warn(LD_BUG, "Couldn't allocate DH key");
+    goto err;
+  }
   if (crypto_dh_get_public(dh, handshake_reply_out, DH_KEY_LEN)) {
     log_info(LD_GENERAL, "crypto_dh_get_public failed.");
     goto err;