summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2019-04-22 17:23:56 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2019-04-22 17:23:56 +0000
commit9a31e880c71dff65f93a45cbfd02e0d1ddcab87f (patch)
tree8c69a1219ba7fd515e82895fa0c90fa35b33efdb /lib/libcrypto
parent7ae474a8f1117ff423f7f22edf82d50240df35b5 (diff)
Add error checking to i2v_ASN1_BIT_STRING().
ok jsing
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/x509v3/v3_bitst.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/libcrypto/x509v3/v3_bitst.c b/lib/libcrypto/x509v3/v3_bitst.c
index 039faf2fd67..178131edbb8 100644
--- a/lib/libcrypto/x509v3/v3_bitst.c
+++ b/lib/libcrypto/x509v3/v3_bitst.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: v3_bitst.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */
+/* $OpenBSD: v3_bitst.c,v 1.15 2019/04/22 17:23:55 tb Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 1999.
*/
@@ -127,12 +127,26 @@ i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, ASN1_BIT_STRING *bits,
STACK_OF(CONF_VALUE) *ret)
{
BIT_STRING_BITNAME *bnam;
+ STACK_OF(CONF_VALUE) *free_ret;
- for (bnam = method->usr_data; bnam->lname; bnam++) {
- if (ASN1_BIT_STRING_get_bit(bits, bnam->bitnum))
- X509V3_add_value(bnam->lname, NULL, &ret);
+ if (ret == NULL) {
+ if ((free_ret = ret = sk_CONF_VALUE_new_null()) == NULL)
+ return NULL;
+ }
+
+ for (bnam = method->usr_data; bnam->lname != NULL; bnam++) {
+ if (!ASN1_BIT_STRING_get_bit(bits, bnam->bitnum))
+ continue;
+ if (!X509V3_add_value(bnam->lname, NULL, &ret))
+ goto err;
}
+
return ret;
+
+ err:
+ sk_CONF_VALUE_pop_free(free_ret, X509V3_conf_free);
+
+ return NULL;
}
ASN1_BIT_STRING *