summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs7/bio_pk7.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2007-05-10 17:37:15 +0000
committerDr. Stephen Henson <steve@openssl.org>2007-05-10 17:37:15 +0000
commit62178961456bae47fae35a3960b4d4d70995c9e3 (patch)
tree007c29fd1b14137a3a2a2f99f59cda3bbf34d384 /crypto/pkcs7/bio_pk7.c
parentee7ca0941aa245f1f6b01fca03228aabb72c51cb (diff)
Improve error detection when streaming S/MIME.
Only use streaming when appropriate for detached data in smime utility.
Diffstat (limited to 'crypto/pkcs7/bio_pk7.c')
-rw-r--r--crypto/pkcs7/bio_pk7.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/crypto/pkcs7/bio_pk7.c b/crypto/pkcs7/bio_pk7.c
index 533e596a1c..581ba09f7a 100644
--- a/crypto/pkcs7/bio_pk7.c
+++ b/crypto/pkcs7/bio_pk7.c
@@ -114,13 +114,17 @@ BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7)
out = BIO_push(asn_bio, out);
+ if (!p7aux || !asn_bio || !out)
+ goto err;
+
BIO_asn1_set_prefix(asn_bio, pkcs7_prefix, pkcs7_prefix_free);
BIO_asn1_set_suffix(asn_bio, pkcs7_suffix, pkcs7_suffix_free);
/* Now initialize BIO for PKCS#7 output */
p7bio = PKCS7_dataInit(p7, out);
- PKCS7_stream(&boundary, p7);
+ if (!p7bio || !PKCS7_stream(&boundary, p7))
+ goto err;
p7aux->p7 = p7;
p7aux->p7bio = p7bio;
@@ -131,6 +135,14 @@ BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7)
return p7bio;
+ err:
+ if (p7bio)
+ BIO_free(p7bio);
+ if (asn_bio)
+ BIO_free(asn_bio);
+ if (p7aux)
+ OPENSSL_free(p7aux);
+ return NULL;
}
static int pkcs7_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg)