]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
asn1: add ASN1_STRING_set() check result
authoratishkov <a.tishkov@aladdin.ru>
Fri, 28 Jul 2023 10:12:38 +0000 (13:12 +0300)
committerTodd Short <todd.short@me.com>
Fri, 4 Aug 2023 17:29:17 +0000 (13:29 -0400)
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/21587)

crypto/asn1/asn1_gen.c

index a7ec79faa9eaf7116fef843abf5b4d40e6c58ba9..1ed9d2afcffbfb0a7ca51d35b7f82fc91a620f61 100644 (file)
@@ -698,9 +698,12 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
             atmp->value.asn1_string->data = rdata;
             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)) {
+                ERR_raise(ERR_LIB_ASN1, ERR_R_ASN1_LIB);
+                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)) {