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

[or-cvs] r13132: Do not segfault if symetric key generation somehow fails in (in tor/trunk: . src/common)



Author: nickm
Date: 2008-01-14 14:00:28 -0500 (Mon, 14 Jan 2008)
New Revision: 13132

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/common/crypto.c
Log:
 r17613@catbus:  nickm | 2008-01-14 13:52:44 -0500
 Do not segfault if symetric key generation somehow fails in crypto_hybrid_encrypt.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r17613] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-01-14 19:00:26 UTC (rev 13131)
+++ tor/trunk/ChangeLog	2008-01-14 19:00:28 UTC (rev 13132)
@@ -45,6 +45,8 @@
     - 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)

Modified: tor/trunk/src/common/crypto.c
===================================================================
--- tor/trunk/src/common/crypto.c	2008-01-14 19:00:26 UTC (rev 13131)
+++ tor/trunk/src/common/crypto.c	2008-01-14 19:00:28 UTC (rev 13132)
@@ -858,8 +858,10 @@
   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;
 }