aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorMarek Majkowski <marek@popcount.org>2013-06-06 12:13:24 +0100
committerMarek Majkowski <marek@popcount.org>2013-06-06 12:13:24 +0100
commit6f1c67195c6a477d16d9ef7a97bd2da86fdfd225 (patch)
treefe1dcf5b0454363cb2ecb8d31f3304622d5bcee1 /src/common
parent2132d036e371210052ebea7dbf9905abc824eee2 (diff)
downloadtor-6f1c67195c6a477d16d9ef7a97bd2da86fdfd225.tar.gz
tor-6f1c67195c6a477d16d9ef7a97bd2da86fdfd225.zip
Bug #5170 - also simplify i2d_DHparams
Diffstat (limited to 'src/common')
-rw-r--r--src/common/crypto.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 40e15bb37e..adbf6396d0 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1688,7 +1688,7 @@ crypto_store_dynamic_dh_modulus(const char *fname)
{
int len, new_len;
DH *dh = NULL;
- unsigned char *dh_string_repr = NULL, *cp = NULL;
+ unsigned char *dh_string_repr = NULL;
char *base64_encoded_dh = NULL;
char *file_string = NULL;
int retval = -1;
@@ -1712,15 +1712,8 @@ crypto_store_dynamic_dh_modulus(const char *fname)
if (!BN_set_word(dh->g, DH_GENERATOR))
goto done;
- len = i2d_DHparams(dh, NULL);
- if (len < 0) {
- log_warn(LD_CRYPTO, "Error occured while DER encoding DH modulus (1).");
- goto done;
- }
-
- cp = dh_string_repr = tor_malloc_zero(len+1);
- len = i2d_DHparams(dh, &cp);
- if ((len < 0) || ((cp - dh_string_repr) != len)) {
+ len = i2d_DHparams(dh, &dh_string_repr);
+ if ((len < 0) || (dh_string_repr == NULL)) {
log_warn(LD_CRYPTO, "Error occured while DER encoding DH modulus (2).");
goto done;
}
@@ -1747,7 +1740,7 @@ crypto_store_dynamic_dh_modulus(const char *fname)
done:
if (dh)
DH_free(dh);
- tor_free(dh_string_repr);
+ OPENSSL_free(dh_string_repr);
tor_free(base64_encoded_dh);
tor_free(file_string);