]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Fix a mem leak 68/head
authorMatt Caswell <matt@openssl.org>
Tue, 17 Jul 2018 09:47:08 +0000 (10:47 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 17 Jul 2018 09:47:08 +0000 (10:47 +0100)
Ensure the grasshopper ciphers are destroyed on engine destroy.

gost_eng.c
gost_grasshopper_cipher.c
gost_grasshopper_cipher.h

index 16316a16949db7de9b6c4acf7bb4bc2566821cb4..517a7da2e6a0d2f95b5dd69373ce0e2783fb0a2b 100644 (file)
@@ -110,6 +110,7 @@ static int gost_engine_destroy(ENGINE* e) {
     imit_gost_cp_12_destroy();
 
     cipher_gost_destroy();
+    cipher_gost_grasshopper_destroy();
 
     gost_param_free();
 
index c797fe1ca042d364767ba8f5e14a8d32cd9c1dfa..2cce25176a1e43bf09f273472c9c9444272c612c 100644 (file)
@@ -650,6 +650,20 @@ const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_ctr() {
     return cipher_gost_grasshopper(EVP_CIPH_CTR_MODE, GRASSHOPPER_CIPHER_CTR);
 }
 
+void cipher_gost_grasshopper_destroy(void)
+{
+    EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_ECB]);
+    gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_ECB] = NULL;
+    EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CBC]);
+    gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CBC] = NULL;
+    EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_OFB]);
+    gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_OFB] = NULL;
+    EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CFB]);
+    gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CFB] = NULL;
+    EVP_CIPHER_meth_free(gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CTR]);
+    gost_grasshopper_ciphers[GRASSHOPPER_CIPHER_CTR] = NULL;
+}
+
 #if defined(__cplusplus)
 }
 #endif
index edd45a42af8cfb77dda134b700e3a23e2b3123dd..08aac05b8b95d32fe84aa74f99eed0a4a5510d76 100644 (file)
@@ -100,6 +100,8 @@ extern const EVP_CIPHER* cipher_gost_grasshopper_ofb();
 extern const EVP_CIPHER* cipher_gost_grasshopper_cfb();
 extern const EVP_CIPHER* cipher_gost_grasshopper_ctr();
 
+void cipher_gost_grasshopper_destroy(void);
+
 #if defined(__cplusplus)
 }
 #endif