summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2023-03-15 06:28:56 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2023-03-15 06:28:56 +0000
commit3c8eedf495ecdbbe1b7420e46136ca5bf339453a (patch)
treea3d033e582ee9281c6f181dcbf63904f438bbbce /lib
parentc709057481a1c3cb7ef1978e324042aa0b5ab48a (diff)
Push calloc() of ndef_aux down as far as possible and
pull the setting of the ex_arg up, so we can do error checking. ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/asn1/bio_ndef.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/libcrypto/asn1/bio_ndef.c b/lib/libcrypto/asn1/bio_ndef.c
index 7c8428f606c..606b08a2861 100644
--- a/lib/libcrypto/asn1/bio_ndef.c
+++ b/lib/libcrypto/asn1/bio_ndef.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bio_ndef.c,v 1.18 2023/03/15 06:22:42 tb Exp $ */
+/* $OpenBSD: bio_ndef.c,v 1.19 2023/03/15 06:28:55 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project.
*/
@@ -110,9 +110,6 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
goto err;
}
- if ((ndef_aux = calloc(1, sizeof(NDEF_SUPPORT))) == NULL)
- goto err;
-
if ((asn_bio = BIO_new(BIO_f_asn1())) == NULL)
goto err;
@@ -125,6 +122,13 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
if (BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free) <= 0)
goto err;
+ if ((ndef_aux = calloc(1, sizeof(*ndef_aux))) == NULL)
+ goto err;
+ if (BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux) <= 0) {
+ free(ndef_aux);
+ goto err;
+ }
+
/* Now let callback prepend any digest, cipher etc BIOs
* ASN1 structure needs.
*/
@@ -142,14 +146,11 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
ndef_aux->boundary = sarg.boundary;
ndef_aux->out = asn_bio;
- BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux);
-
return sarg.ndef_bio;
err:
BIO_pop(pop_bio);
BIO_free(asn_bio);
- free(ndef_aux);
return NULL;
}