aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_pkcs7.c
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-07 12:13:37 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-08-16 14:22:08 +0900
commit50d3582691d7cfafc13139aeff7e9e78fba15b39 (patch)
treee792cc711c4fed3b49be4a71c139a8d55f6537d2 /ext/openssl/ossl_pkcs7.c
parentf3ccb756d7fb501b2b57e975d9a521e0055a8397 (diff)
downloadruby-openssl-50d3582691d7cfafc13139aeff7e9e78fba15b39.tar.gz
pkcs7: fix a memory leak in PKCS7#add_data
The BIO returned by PKCS7_dataInit() must be free'd using BIO_free_all().
Diffstat (limited to 'ext/openssl/ossl_pkcs7.c')
-rw-r--r--ext/openssl/ossl_pkcs7.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
index 61046523..fd58b48b 100644
--- a/ext/openssl/ossl_pkcs7.c
+++ b/ext/openssl/ossl_pkcs7.c
@@ -839,12 +839,12 @@ ossl_pkcs7_add_data(VALUE self, VALUE data)
char buf[4096];
int len;
- in = ossl_obj2bio(data);
GetPKCS7(self, pkcs7);
if(PKCS7_type_is_signed(pkcs7)){
if(!PKCS7_content_new(pkcs7, NID_pkcs7_data))
ossl_raise(ePKCS7Error, NULL);
}
+ in = ossl_obj2bio(data);
if(!(out = PKCS7_dataInit(pkcs7, NULL))) goto err;
for(;;){
if((len = BIO_read(in, buf, sizeof(buf))) <= 0)
@@ -856,7 +856,7 @@ ossl_pkcs7_add_data(VALUE self, VALUE data)
ossl_pkcs7_set_data(self, Qnil);
err:
- BIO_free(out);
+ BIO_free_all(out);
BIO_free(in);
if(ERR_peek_error()){
ossl_raise(ePKCS7Error, NULL);