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
-/* $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.
*/
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;
* ASN1 structure needs.
*/
- sarg.out = out;
+ sarg.out = asn_bio;
sarg.ndef_bio = NULL;
sarg.boundary = NULL;
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);