]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ASN1_parse_dump(): allow NULL BIO input, to simplify applications not needing output
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Mon, 14 Jun 2021 10:58:40 +0000 (12:58 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Tue, 15 Jun 2021 12:23:29 +0000 (14:23 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15722)

crypto/asn1/asn1_parse.c

index 83ac535cc3754d5deb0f7523cc44dae1b5fdbf12..a131713d73781e2a8ee1531d70a848a5abc3c36c 100644 (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