ASN1_parse_dump(): allow NULL BIO input, to simplify applications not needing output

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)
This commit is contained in:
Dr. David von Oheimb 2021-06-14 12:58:40 +02:00 committed by Dr. David von Oheimb
parent bb19b9d456
commit 515480be79

View File

@ -41,15 +41,16 @@ static int asn1_print_info(BIO *bp, long offset, int depth, int hl, long len,
offset, depth, (long)hl, p) <= 0)
goto err;
}
if (BIO_set_prefix(bp, str) <= 0) {
if ((bp = BIO_push(BIO_new(BIO_f_prefix()), bp)) == NULL)
if (bp != NULL) {
if (BIO_set_prefix(bp, str) <= 0) {
if ((bp = BIO_push(BIO_new(BIO_f_prefix()), bp)) == NULL)
goto err;
pop_f_prefix = 1;
}
saved_indent = BIO_get_indent(bp);
if (BIO_set_prefix(bp, str) <= 0 || BIO_set_indent(bp, indent) < 0)
goto err;
pop_f_prefix = 1;
}
saved_indent = BIO_get_indent(bp);
if (BIO_set_prefix(bp, str) <= 0
|| BIO_set_indent(bp, indent) < 0)
goto err;
/*
* BIO_set_prefix made a copy of |str|, so we can safely use it for