From 6d6c47980e943f3946b3894ac341d61e3c908c92 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 5 Aug 2008 15:55:53 +0000 Subject: [PATCH] Correctly handle errors in CMS I/O code. --- crypto/asn1/asn_mime.c | 2 ++ crypto/cms/cms_smime.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c index 8fbdf21337..c1d1b12291 100644 --- a/crypto/asn1/asn_mime.c +++ b/crypto/asn1/asn_mime.c @@ -592,6 +592,8 @@ int SMIME_text(BIO *in, BIO *out) sk_MIME_HEADER_pop_free(headers, mime_hdr_free); while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) BIO_write(out, iobuf, len); + if (len < 0) + return 0; return 1; } diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index 8e3221b726..dec8ef32f8 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -89,11 +89,13 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags) if (!BIO_get_cipher_status(in)) goto err; } + if (i < 0) + goto err; break; } - if (tmpout) - BIO_write(tmpout, buf, i); + if (tmpout && (BIO_write(tmpout, buf, i) != i)) + goto err; } if(flags & CMS_TEXT) -- 2.25.1