diff options
author | miod <> | 2015-07-18 14:40:59 +0000 |
---|---|---|
committer | miod <> | 2015-07-18 14:40:59 +0000 |
commit | fb4b9046bf049484f0a34a724bc5b6c7a17f967a (patch) | |
tree | c74957e7e8a714ac10a0f4f77da884dfd2183ae1 /src/lib/libcrypto/asn1 | |
parent | dd1a8feef3ef54128aab53a720a711d669b98c21 (diff) | |
download | openbsd-fb4b9046bf049484f0a34a724bc5b6c7a17f967a.tar.gz openbsd-fb4b9046bf049484f0a34a724bc5b6c7a17f967a.tar.bz2 openbsd-fb4b9046bf049484f0a34a724bc5b6c7a17f967a.zip |
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 'src/lib/libcrypto/asn1')
-rw-r--r-- | src/lib/libcrypto/asn1/asn1_gen.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_gen.c b/src/lib/libcrypto/asn1/asn1_gen.c index 384088308f..08a5dec4a6 100644 --- a/src/lib/libcrypto/asn1/asn1_gen.c +++ b/src/lib/libcrypto/asn1/asn1_gen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: asn1_gen.c,v 1.13 2015/02/12 06:04:24 jsg Exp $ */ | 1 | /* $OpenBSD: asn1_gen.c,v 1.14 2015/07/18 14:40:59 miod 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 2002. | 3 | * project 2002. |
4 | */ | 4 | */ |
@@ -740,9 +740,14 @@ asn1_str2type(const char *str, int format, int utype) | |||
740 | atmp->value.asn1_string->length = rdlen; | 740 | atmp->value.asn1_string->length = rdlen; |
741 | atmp->value.asn1_string->type = utype; | 741 | atmp->value.asn1_string->type = utype; |
742 | 742 | ||
743 | } else if (format == ASN1_GEN_FORMAT_ASCII) | 743 | } else if (format == ASN1_GEN_FORMAT_ASCII) { |
744 | ASN1_STRING_set(atmp->value.asn1_string, str, -1); | 744 | if (ASN1_STRING_set(atmp->value.asn1_string, str, |
745 | else if ((format == ASN1_GEN_FORMAT_BITLIST) && | 745 | -1) == 0) { |
746 | ASN1err(ASN1_F_ASN1_STR2TYPE, | ||
747 | ERR_R_MALLOC_FAILURE); | ||
748 | goto bad_str; | ||
749 | } | ||
750 | } else if ((format == ASN1_GEN_FORMAT_BITLIST) && | ||
746 | (utype == V_ASN1_BIT_STRING)) { | 751 | (utype == V_ASN1_BIT_STRING)) { |
747 | if (!CONF_parse_list(str, ',', 1, bitstr_cb, | 752 | if (!CONF_parse_list(str, ',', 1, bitstr_cb, |
748 | atmp->value.bit_string)) { | 753 | atmp->value.bit_string)) { |