Fix SMIME_crlf_copy() to properly report an error
If the BIO unexpectedly fails to flush then SMIME_crlf_copy() was not correctly reporting the error. We modify it to properly propagate the error condition. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19918)
This commit is contained in:
parent
e51dd6ee1b
commit
9e5bd8923b
@ -515,6 +515,7 @@ int SMIME_crlf_copy(BIO *in, BIO *out, int flags)
|
|||||||
char eol;
|
char eol;
|
||||||
int len;
|
int len;
|
||||||
char linebuf[MAX_SMLEN];
|
char linebuf[MAX_SMLEN];
|
||||||
|
int ret;
|
||||||
/*
|
/*
|
||||||
* Buffer output so we don't write one line at a time. This is useful
|
* Buffer output so we don't write one line at a time. This is useful
|
||||||
* when streaming as we don't end up with one OCTET STRING per line.
|
* when streaming as we don't end up with one OCTET STRING per line.
|
||||||
@ -552,9 +553,12 @@ int SMIME_crlf_copy(BIO *in, BIO *out, int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)BIO_flush(out);
|
ret = BIO_flush(out);
|
||||||
BIO_pop(out);
|
BIO_pop(out);
|
||||||
BIO_free(bf);
|
BIO_free(bf);
|
||||||
|
if (ret <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,13 +261,9 @@ static int test_bio_i2d_ASN1_mime(void)
|
|||||||
|
|
||||||
error_callback_fired = 0;
|
error_callback_fired = 0;
|
||||||
|
|
||||||
/*
|
if (!TEST_false(i2d_ASN1_bio_stream(out, (ASN1_VALUE*) p7, bio,
|
||||||
* The call succeeds even if the input stream ends unexpectedly as
|
SMIME_STREAM | SMIME_BINARY,
|
||||||
* there is no handling for this case in SMIME_crlf_copy().
|
ASN1_ITEM_rptr(PKCS7))))
|
||||||
*/
|
|
||||||
if (!TEST_true(i2d_ASN1_bio_stream(out, (ASN1_VALUE*) p7, bio,
|
|
||||||
SMIME_STREAM | SMIME_BINARY,
|
|
||||||
ASN1_ITEM_rptr(PKCS7))))
|
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
if (!TEST_int_eq(error_callback_fired, 1))
|
if (!TEST_int_eq(error_callback_fired, 1))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user