]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Correctly detect BIO_new failures
authorNick Mathewson <nickm@torproject.org>
Tue, 25 Jan 2011 23:26:49 +0000 (18:26 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 25 Jan 2011 23:26:49 +0000 (18:26 -0500)
This bug was noticed by cypherpunks; fixes bug 2378.

Bugfix on svn commit r110.

changes/bug2378
src/common/crypto.c

index a3ae196dc23379c060fbb028f82353f22c0b4644..227968869f354ba0703707899163d1a048e0889e 100644 (file)
@@ -1,3 +1,8 @@
+  o Minor bugfixes
+    - Correctly detect failure to allocate an OpenSSL BIO.  Fixes bug 2378;
+      found by "cypherpunks".   This bug was introduced before the
+      first Tor release, in svn commit r110.
+
   o Minor code simplifications and refactorings
     - Always treat failure to allocate an RSA key as an unrecoverable
       allocation error.
index 09d7fc886b15c0a4aca19f374dc04ad297bb3161..cfbc002dca2c2d9ddf1f2ab06fcca4a804cf4cd9 100644 (file)
@@ -524,6 +524,8 @@ crypto_pk_read_private_key_from_string(crypto_pk_env_t *env,
 
   /* Create a read-only memory BIO, backed by the string 's' */
   b = BIO_new_mem_buf((char*)s, (int)len);
+  if (!b)
+    return -1;
 
   if (env->key)
     RSA_free(env->key);
@@ -584,6 +586,8 @@ crypto_pk_write_key_to_string_impl(crypto_pk_env_t *env, char **dest,
   tor_assert(dest);
 
   b = BIO_new(BIO_s_mem()); /* Create a memory BIO */
+  if (!b)
+    return -1;
 
   /* Now you can treat b as if it were a file.  Just use the
    * PEM_*_bio_* functions instead of the non-bio variants.
@@ -651,6 +655,8 @@ crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src,
   tor_assert(len<INT_MAX);
 
   b = BIO_new(BIO_s_mem()); /* Create a memory BIO */
+  if (!b)
+    return -1;
 
   BIO_write(b, src, (int)len);