diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2015-07-18 14:41:00 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2015-07-18 14:41:00 +0000 |
commit | bd224a302c9b95d18cc6700fc8365c27ad688174 (patch) | |
tree | b513aed882833ea67b0640386c1b3bddda18d103 /lib/libcrypto/asn1 | |
parent | 3da37385c7b5675050f0c850943619c3bbb13d3c (diff) |
Check the return value of ASN1_STRING_set(), for it may fail to allocate
memory. Coverity CID 24810, 24846.
ok bcook@ doug@
Diffstat (limited to 'lib/libcrypto/asn1')
-rw-r--r-- | lib/libcrypto/asn1/asn1_gen.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libcrypto/asn1/asn1_gen.c b/lib/libcrypto/asn1/asn1_gen.c index 384088308f7..08a5dec4a67 100644 --- a/lib/libcrypto/asn1/asn1_gen.c +++ b/lib/libcrypto/asn1/asn1_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_gen.c,v 1.13 2015/02/12 06:04:24 jsg Exp $ */ +/* $OpenBSD: asn1_gen.c,v 1.14 2015/07/18 14:40:59 miod Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2002. */ @@ -740,9 +740,14 @@ asn1_str2type(const char *str, int format, int utype) atmp->value.asn1_string->length = rdlen; atmp->value.asn1_string->type = utype; - } else if (format == ASN1_GEN_FORMAT_ASCII) - ASN1_STRING_set(atmp->value.asn1_string, str, -1); - else if ((format == ASN1_GEN_FORMAT_BITLIST) && + } else if (format == ASN1_GEN_FORMAT_ASCII) { + if (ASN1_STRING_set(atmp->value.asn1_string, str, + -1) == 0) { + ASN1err(ASN1_F_ASN1_STR2TYPE, + ERR_R_MALLOC_FAILURE); + goto bad_str; + } + } else if ((format == ASN1_GEN_FORMAT_BITLIST) && (utype == V_ASN1_BIT_STRING)) { if (!CONF_parse_list(str, ',', 1, bitstr_cb, atmp->value.bit_string)) { |