int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags,
const ASN1_ITEM *it)
{
+ int rv = 1;
+
/* If streaming create stream BIO and copy all content through it */
if (flags & SMIME_STREAM) {
BIO *bio, *tbio;
ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE);
return 0;
}
- SMIME_crlf_copy(in, bio, flags);
+ if (!SMIME_crlf_copy(in, bio, flags)) {
+ rv = 0;
+ }
+
(void)BIO_flush(bio);
/* Free up successive BIOs until we hit the old output BIO */
do {
*/
else
ASN1_item_i2d_bio(it, out, val);
- return 1;
+ return rv;
}
/* Base 64 read and write of ASN1 structure */
* set up to finalise when it is written through.
*/
if (!(flags & SMIME_DETACHED) || (flags & PKCS7_REUSE_DIGEST)) {
- SMIME_crlf_copy(data, out, flags);
- return 1;
+ return SMIME_crlf_copy(data, out, flags);
}
if (!aux || !aux->asn1_cb) {
return 0;
/* Copy data across, passing through filter BIOs for processing */
- SMIME_crlf_copy(data, sarg.ndef_bio, flags);
+ if (!SMIME_crlf_copy(data, sarg.ndef_bio, flags))
+ rv = 0;
/* Finalize structure */
if (aux->asn1_cb(ASN1_OP_DETACHED_POST, &val, it, &sarg) <= 0)
* when streaming as we don't end up with one OCTET STRING per line.
*/
bf = BIO_new(BIO_f_buffer());
- if (bf == NULL)
+ if (bf == NULL) {
+ ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE);
return 0;
+ }
out = BIO_push(bf, out);
if (flags & SMIME_BINARY) {
while ((len = BIO_read(in, linebuf, MAX_SMLEN)) > 0)
* Don't use SMIME_TEXT for verify: it adds headers and we want to
* remove them.
*/
- SMIME_crlf_copy(dcont, cmsbio, flags & ~SMIME_TEXT);
+ if (!SMIME_crlf_copy(dcont, cmsbio, flags & ~SMIME_TEXT))
+ goto err;
if (flags & CMS_TEXT) {
if (!SMIME_text(tmpout, out)) {
return 0;
}
- SMIME_crlf_copy(data, cmsbio, flags);
+ if (!SMIME_crlf_copy(data, cmsbio, flags)) {
+ goto err;
+ }
(void)BIO_flush(cmsbio);