diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-10-05 10:25:42 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-10-10 23:14:30 -0400 |
commit | 40f0d111c2263b44d30d47a292b3bb9ef3a01a08 (patch) | |
tree | c4240fe0ac13ecc74f54ef165f64e148b6db8176 | |
parent | ce102f7a59eb286b18d5f7522467aa152bff7e82 (diff) | |
download | tor-40f0d111c2263b44d30d47a292b3bb9ef3a01a08.tar.gz tor-40f0d111c2263b44d30d47a292b3bb9ef3a01a08.zip |
Fix some more issues wrt tor_cert_new found by asn
-rw-r--r-- | src/common/tortls.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c index 206ac3be49..247e9eec07 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -706,9 +706,13 @@ tor_cert_new(X509 *x509_cert) tor_cert_t *cert; EVP_PKEY *pkey; RSA *rsa; - int length = i2d_X509(x509_cert, NULL), length2; + int length, length2; unsigned char *cp; + if (!x509_cert) + return NULL; + + length = i2d_X509(x509_cert, NULL); cert = tor_malloc_zero(sizeof(tor_cert_t)); if (length <= 0) { tor_free(cert); @@ -766,7 +770,6 @@ tor_cert_decode(const uint8_t *certificate, size_t certificate_len) } newcert = tor_cert_new(x509); if (!newcert) { - X509_free(x509); return NULL; } if (newcert->encoded_len != certificate_len || @@ -1118,6 +1121,8 @@ tor_tls_context_new(crypto_pk_env_t *identity, unsigned int key_lifetime) result->my_link_cert = tor_cert_new(X509_dup(cert)); result->my_id_cert = tor_cert_new(X509_dup(idcert)); result->my_auth_cert = tor_cert_new(X509_dup(authcert)); + if (!result->my_link_cert || !result->my_id_cert || !result->my_auth_cert) + goto error; result->link_key = crypto_pk_dup_key(rsa); result->auth_key = crypto_pk_dup_key(rsa_auth); |