aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-19 09:27:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-10-19 09:27:09 +0100
commitf3ba49cebe8a0ccb86299cfaaac6636b64eb1081 (patch)
treeb6a87614d9e3f7d5ce9c5e84ef1b7d2b7db58fdb /src
parent134c44511e1a863766e54deaeade909eecc97278 (diff)
downloadrspamd-f3ba49cebe8a0ccb86299cfaaac6636b64eb1081.tar.gz
rspamd-f3ba49cebe8a0ccb86299cfaaac6636b64eb1081.zip
Fix memory allocation for openssl objects
Diffstat (limited to 'src')
-rw-r--r--src/libcryptobox/cryptobox.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libcryptobox/cryptobox.c b/src/libcryptobox/cryptobox.c
index 6282dcca4..0bc52288a 100644
--- a/src/libcryptobox/cryptobox.c
+++ b/src/libcryptobox/cryptobox.c
@@ -50,6 +50,8 @@
#ifdef HAVE_USABLE_OPENSSL
#include <openssl/evp.h>
#include <openssl/ec.h>
+
+#define CRYPTOBOX_CURVE_NID NID_X9_62_prime256v1
#endif
#include <signal.h>
@@ -250,11 +252,12 @@ rspamd_cryptobox_keypair (rspamd_pk_t pk, rspamd_sk_t sk)
g_assert (0);
#else
EC_KEY *ec_sec;
- const BIGNUM *bn_sec, *bn_pub;
+ const BIGNUM *bn_sec;
+ BIGNUM *bn_pub;
const EC_POINT *ec_pub;
gint len;
- ec_sec = EC_KEY_new_by_curve_name (NID_X9_62_prime256v1);
+ ec_sec = EC_KEY_new_by_curve_name (CRYPTOBOX_CURVE_NID);
g_assert (ec_sec != NULL);
g_assert (EC_KEY_generate_key (ec_sec) != 0);
@@ -266,11 +269,13 @@ rspamd_cryptobox_keypair (rspamd_pk_t pk, rspamd_sk_t sk)
ec_pub, POINT_CONVERSION_COMPRESSED, NULL, NULL);
len = BN_num_bits (bn_sec) / NBBY;
- g_assert (len <= sizeof (rspamd_sk_t));
+ g_assert (len <= (gint)sizeof (rspamd_sk_t));
BN_bn2bin (bn_sec, sk);
len = BN_num_bits (bn_pub) / NBBY;
- g_assert (len <= sizeof (rspamd_pk_t));
+ g_assert (len <= (gint)sizeof (rspamd_pk_t));
BN_bn2bin (bn_pub, pk);
+ BN_free (bn_pub);
+ EC_KEY_free (ec_sec);
#endif
}
}