From fc7471682dc0a11ebac8c980c6afce3ab21dc45f Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 13 Mar 2023 07:31:09 +0000 Subject: Stop confusing out and asn_bio in BIO_new_NDEF() BIO_new_NDEF() sets up an ASN.1 BIO to the output chain and then adds even more BIOs. Since BIO_push(bio, new_tail) returns bio on success, after the if ((out = BIO_push(asn_bio, out)) != NULL) the 'out' BIO and the 'asn_bio' are the same. The code then goes on and uses one or the other. This is very confusing. Simply stop using out once it's appended to asn_bio. ok jsing --- src/lib/libcrypto/asn1/bio_ndef.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c index 182ca52960..d6642e573e 100644 --- a/src/lib/libcrypto/asn1/bio_ndef.c +++ b/src/lib/libcrypto/asn1/bio_ndef.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ndef.c,v 1.16 2023/03/11 16:29:48 tb Exp $ */ +/* $OpenBSD: bio_ndef.c,v 1.17 2023/03/13 07:31:09 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -116,7 +116,7 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) if ((asn_bio = BIO_new(BIO_f_asn1())) == NULL) goto err; - if ((out = BIO_push(asn_bio, out)) == NULL) + if (BIO_push(asn_bio, out) == NULL) goto err; pop_bio = asn_bio; @@ -127,7 +127,7 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) * ASN1 structure needs. */ - sarg.out = out; + sarg.out = asn_bio; sarg.ndef_bio = NULL; sarg.boundary = NULL; @@ -138,7 +138,7 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it) ndef_aux->it = it; ndef_aux->ndef_bio = sarg.ndef_bio; ndef_aux->boundary = sarg.boundary; - ndef_aux->out = out; + ndef_aux->out = asn_bio; BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux); -- cgit v1.2.3-55-g6feb