Browse Source

r17613@catbus: nickm | 2008-01-14 13:52:44 -0500
Do not segfault if symetric key generation somehow fails in crypto_hybrid_encrypt.


svn:r13132

Nick Mathewson 16 years ago
parent
commit
d7fb8a34ac
2 changed files with 6 additions and 2 deletions
  1. 2 0
      ChangeLog
  2. 4 2
      src/common/crypto.c

+ 2 - 0
ChangeLog

@@ -45,6 +45,8 @@ Changes in version 0.2.0.16-alpha - 2008-01-??
     - Make bridges round geoip info up, not down.
     - Avoid a spurious free on base64 failure.  Bugfix on 0.1.2.
     - Detect more kinds of possible internal error.
+    - Avoid possible segfault if key generation fails in
+      crypto_pk_hybrid_encrypt. Bugfix on 0.2.0.
 
   o Minor features (controller):
     - Get NS events working again.  (Patch from tup)

+ 4 - 2
src/common/crypto.c

@@ -858,8 +858,10 @@ crypto_pk_public_hybrid_encrypt(crypto_pk_env_t *env,
   crypto_free_cipher_env(cipher);
   return outlen + symlen;
  err:
-  memset(buf, 0, pkeylen);
-  tor_free(buf);
+  if (buf) {
+    memset(buf, 0, pkeylen);
+    tor_free(buf);
+  }
   if (cipher) crypto_free_cipher_env(cipher);
   return -1;
 }