diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-01-25 18:26:49 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-01-25 18:26:49 -0500 |
commit | e80bdfb4a02c6f8313baec6e9b00ec3baac3da87 (patch) | |
tree | 441f608fa1498456d73009832f67c30ea6838758 /src/common | |
parent | bfde636aaddf22f68c090a76aa6387975a57c308 (diff) | |
download | tor-e80bdfb4a02c6f8313baec6e9b00ec3baac3da87.tar.gz tor-e80bdfb4a02c6f8313baec6e9b00ec3baac3da87.zip |
Correctly detect BIO_new failures
This bug was noticed by cypherpunks; fixes bug 2378.
Bugfix on svn commit r110.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/crypto.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 09d7fc886b..cfbc002dca 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -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); |