diff options
author | Matt Caswell <matt@openssl.org> | 2018-03-12 13:56:34 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-03-12 19:09:04 +0000 |
commit | 4718f449a3ecd5efac62b22d0fa9a759a7895dbc (patch) | |
tree | d60c3fcc426b09bb34e5fcf3db350d218936cd06 /crypto/pkcs7 | |
parent | e45b4dd292d8cd2a9f71c88784b72d831b3b6212 (diff) |
Improve error handling in pk7_doit
If a mem allocation failed we would ignore it. This commit fixes it to
always check.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5596)
Diffstat (limited to 'crypto/pkcs7')
-rw-r--r-- | crypto/pkcs7/pk7_doit.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c index c5baf0468d..4585031dd3 100644 --- a/crypto/pkcs7/pk7_doit.c +++ b/crypto/pkcs7/pk7_doit.c @@ -316,16 +316,18 @@ BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio) } if (bio == NULL) { - if (PKCS7_is_detached(p7)) + if (PKCS7_is_detached(p7)) { bio = BIO_new(BIO_s_null()); - else if (os && os->length > 0) + } else if (os && os->length > 0) { bio = BIO_new_mem_buf(os->data, os->length); - if (bio == NULL) { + } else { bio = BIO_new(BIO_s_mem()); if (bio == NULL) goto err; BIO_set_mem_eof_return(bio, 0); } + if (bio == NULL) + goto err; } if (out) BIO_push(out, bio); |