summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorNeil Horman <nhorman@openssl.org>2023-12-07 16:56:39 -0500
committerTomas Mraz <tomas@openssl.org>2024-01-12 10:37:22 +0100
commit0981c20f8efa68bf9d68d7715280f83812c19a7e (patch)
tree4da3299f29238595d3f90c17d992fd9743abda5b /crypto/asn1
parent3cb1b51dddf4deaf5e3886b827f3245d81670bc7 (diff)
Fix NULL pointer deref when parsing the stable section
When parsing the stable section of a config such as this: openssl_conf = openssl_init [openssl_init] stbl_section = mstbl [mstbl] id-tc26 = min Can lead to a SIGSEGV, as the parsing code doesnt recognize min as a proper section name without a trailing colon to associate it with a value. As a result the stack of configuration values has an entry with a null value in it, which leads to the SIGSEGV in do_tcreate when we attempt to pass NULL to strtoul. Fix it by skipping any entry in the config name/value list that has a null value, prior to passing it to stroul Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22988)
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/asn_mstbl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/asn1/asn_mstbl.c b/crypto/asn1/asn_mstbl.c
index 515d8181b6..93c6f61bd9 100644
--- a/crypto/asn1/asn_mstbl.c
+++ b/crypto/asn1/asn_mstbl.c
@@ -72,6 +72,8 @@ static int do_tcreate(const char *value, const char *name)
goto err;
for (i = 0; i < sk_CONF_VALUE_num(lst); i++) {
cnf = sk_CONF_VALUE_value(lst, i);
+ if (cnf->value == NULL)
+ goto err;
if (strcmp(cnf->name, "min") == 0) {
tbl_min = strtoul(cnf->value, &eptr, 0);
if (*eptr)
@@ -98,7 +100,9 @@ static int do_tcreate(const char *value, const char *name)
if (rv == 0) {
if (cnf)
ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_STRING_TABLE_VALUE,
- "field=%s, value=%s", cnf->name, cnf->value);
+ "field=%s, value=%s", cnf->name,
+ cnf->value != NULL ? cnf->value
+ : value);
else
ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_STRING_TABLE_VALUE,
"name=%s, value=%s", name, value);