aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_cryptobox.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/lua_cryptobox.c')
-rw-r--r--src/lua/lua_cryptobox.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c
index 645b2495f..518ae9389 100644
--- a/src/lua/lua_cryptobox.c
+++ b/src/lua/lua_cryptobox.c
@@ -2321,6 +2321,16 @@ lua_cryptobox_gen_dkim_keypair (lua_State *L)
/* Process private key */
rc = i2d_RSAPrivateKey_bio (mbio, r);
+
+ if (rc == 0) {
+ BIO_free (mbio);
+ BN_free (e);
+ RSA_free (r);
+ EVP_PKEY_free (pk);
+
+ return luaL_error (L, "i2d_RSAPrivateKey_bio failed");
+ }
+
len = BIO_get_mem_data (mbio, &data);
b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);
@@ -2334,6 +2344,16 @@ lua_cryptobox_gen_dkim_keypair (lua_State *L)
/* Process public key */
BIO_reset (mbio);
rc = i2d_RSA_PUBKEY_bio (mbio, r);
+
+ if (rc == 0) {
+ BIO_free (mbio);
+ BN_free (e);
+ RSA_free (r);
+ EVP_PKEY_free (pk);
+
+ return luaL_error (L, "i2d_RSA_PUBKEY_bio failed");
+ }
+
len = BIO_get_mem_data (mbio, &data);
b64_data = rspamd_encode_base64 (data, len, -1, &b64_len);