summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-03-15 06:28:55 +0000
committertb <>2023-03-15 06:28:55 +0000
commiteb79ce5c6af378cd9f881d86dda089042af166b9 (patch)
tree247e6907345ac367db0b7ad289d722bdce4a9710 /src/lib
parent73af251f8d8df085aba437aef7f6d763c349a841 (diff)
downloadopenbsd-eb79ce5c6af378cd9f881d86dda089042af166b9.tar.gz
openbsd-eb79ce5c6af378cd9f881d86dda089042af166b9.tar.bz2
openbsd-eb79ce5c6af378cd9f881d86dda089042af166b9.zip
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 'src/lib')
-rw-r--r--src/lib/libcrypto/asn1/bio_ndef.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/libcrypto/asn1/bio_ndef.c b/src/lib/libcrypto/asn1/bio_ndef.c
index 7c8428f606..606b08a286 100644
--- a/src/lib/libcrypto/asn1/bio_ndef.c
+++ b/src/lib/libcrypto/asn1/bio_ndef.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bio_ndef.c,v 1.18 2023/03/15 06:22:42 tb Exp $ */ 1/* $OpenBSD: bio_ndef.c,v 1.19 2023/03/15 06:28:55 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project. 3 * project.
4 */ 4 */
@@ -110,9 +110,6 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
110 goto err; 110 goto err;
111 } 111 }
112 112
113 if ((ndef_aux = calloc(1, sizeof(NDEF_SUPPORT))) == NULL)
114 goto err;
115
116 if ((asn_bio = BIO_new(BIO_f_asn1())) == NULL) 113 if ((asn_bio = BIO_new(BIO_f_asn1())) == NULL)
117 goto err; 114 goto err;
118 115
@@ -125,6 +122,13 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
125 if (BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free) <= 0) 122 if (BIO_asn1_set_suffix(asn_bio, ndef_suffix, ndef_suffix_free) <= 0)
126 goto err; 123 goto err;
127 124
125 if ((ndef_aux = calloc(1, sizeof(*ndef_aux))) == NULL)
126 goto err;
127 if (BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux) <= 0) {
128 free(ndef_aux);
129 goto err;
130 }
131
128 /* Now let callback prepend any digest, cipher etc BIOs 132 /* Now let callback prepend any digest, cipher etc BIOs
129 * ASN1 structure needs. 133 * ASN1 structure needs.
130 */ 134 */
@@ -142,14 +146,11 @@ BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
142 ndef_aux->boundary = sarg.boundary; 146 ndef_aux->boundary = sarg.boundary;
143 ndef_aux->out = asn_bio; 147 ndef_aux->out = asn_bio;
144 148
145 BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux);
146
147 return sarg.ndef_bio; 149 return sarg.ndef_bio;
148 150
149 err: 151 err:
150 BIO_pop(pop_bio); 152 BIO_pop(pop_bio);
151 BIO_free(asn_bio); 153 BIO_free(asn_bio);
152 free(ndef_aux);
153 return NULL; 154 return NULL;
154} 155}
155 156