Correctly handle errors in CMS I/O code.

This commit is contained in:
Dr. Stephen Henson 2008-08-05 15:55:53 +00:00
parent 474b3b1cc8
commit 6d6c47980e
2 changed files with 6 additions and 2 deletions

View File

@ -592,6 +592,8 @@ int SMIME_text(BIO *in, BIO *out)
sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0) while ((len = BIO_read(in, iobuf, sizeof(iobuf))) > 0)
BIO_write(out, iobuf, len); BIO_write(out, iobuf, len);
if (len < 0)
return 0;
return 1; return 1;
} }

View File

@ -89,11 +89,13 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
if (!BIO_get_cipher_status(in)) if (!BIO_get_cipher_status(in))
goto err; goto err;
} }
if (i < 0)
goto err;
break; break;
} }
if (tmpout) if (tmpout && (BIO_write(tmpout, buf, i) != i))
BIO_write(tmpout, buf, i); goto err;
} }
if(flags & CMS_TEXT) if(flags & CMS_TEXT)