diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-08-07 12:13:37 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-08-16 14:22:08 +0900 |
commit | 50d3582691d7cfafc13139aeff7e9e78fba15b39 (patch) | |
tree | e792cc711c4fed3b49be4a71c139a8d55f6537d2 /ext/openssl/ossl_pkcs7.c | |
parent | f3ccb756d7fb501b2b57e975d9a521e0055a8397 (diff) | |
download | ruby-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.c | 4 |
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); |