diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-04-12 10:15:33 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-04-12 10:15:33 +0000 |
commit | 501af5ba89e399d15d46a3ef61a164d2aad99e2f (patch) | |
tree | 8aa5243761bf448e8808325b5d1bdebd28f45e81 /crypto/cms | |
parent | 31d6e7b7badaab97ab80db60ca93f939708ce2ad (diff) |
Update from HEAD.
Diffstat (limited to 'crypto/cms')
-rw-r--r-- | crypto/cms/cms.h | 2 | ||||
-rw-r--r-- | crypto/cms/cms_smime.c | 32 |
2 files changed, 26 insertions, 8 deletions
diff --git a/crypto/cms/cms.h b/crypto/cms/cms.h index e5d776aacf..25f88745f2 100644 --- a/crypto/cms/cms.h +++ b/crypto/cms/cms.h @@ -172,7 +172,7 @@ CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, unsigned int flags); int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, - BIO *data, BIO *dcont, + BIO *dcont, BIO *out, unsigned int flags); int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert); diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index 0f8b6ade43..c42de11f9e 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -125,6 +125,23 @@ static int check_content(CMS_ContentInfo *cms) return 1; } +static void do_free_upto(BIO *f, BIO *upto) + { + if (upto) + { + BIO *tbio; + do + { + tbio = BIO_pop(f); + BIO_free(f); + f = tbio; + } + while (f != upto); + } + else + BIO_free_all(f); + } + int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags) { BIO *cont; @@ -177,7 +194,7 @@ int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out, r = cms_copy_content(out, cont, flags); if (r) r = cms_DigestedData_do_final(cms, cont, 1); - BIO_free_all(cont); + do_free_upto(cont, dcont); return r; } @@ -226,7 +243,7 @@ int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, if (!cont) return 0; r = cms_copy_content(out, cont, flags); - BIO_free_all(cont); + do_free_upto(cont, dcont); return r; } @@ -417,8 +434,9 @@ int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, err: if (dcont && (tmpin == dcont)) - BIO_pop(cmsbio); - BIO_free_all(cmsbio); + do_free_upto(cmsbio, dcont); + else + BIO_free_all(cmsbio); if (cms_certs) sk_X509_pop_free(cms_certs, X509_free); @@ -689,7 +707,7 @@ int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert, if (!cont) return 0; r = cms_copy_content(out, cont, flags); - BIO_free_all(cont); + do_free_upto(cont, dcont); return r; } @@ -717,7 +735,7 @@ int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags) ret = 1; err: - BIO_free_all(cmsbio); + do_free_upto(cmsbio, dcont); return ret; @@ -744,7 +762,7 @@ int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, if (!cont) return 0; r = cms_copy_content(out, cont, flags); - BIO_free_all(cont); + do_free_upto(cont, dcont); return r; } |