summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Horman <nhorman@openssl.org>2024-01-26 11:33:18 -0500
committerNeil Horman <nhorman@openssl.org>2024-01-30 10:28:58 -0500
commit4ee81ec4e0c2842d9ec1549a83516000b4685a4d (patch)
treecfe755a967136f9aba8a84df7ce065fc88e2a734
parenta1572c9a10bd07aee5daeb19ac97b01a21831d2d (diff)
fix missing null check in kdf_test_ctrl
Coverity issue 1453632 noted a missing null check in kdf_test_ctrl recently. If a malformed value is passed in from the test file that does not contain a ':' character, the p variable will be NULL, leading to a NULL derefence prepare_from_text Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com> (Merged from https://github.com/openssl/openssl/pull/23398) (cherry picked from commit 6ca1d3ee81b61bc973e4e1079ec68ac73331c159)
-rw-r--r--test/evp_test.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/test/evp_test.c b/test/evp_test.c
index 782841a692..2701040dab 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -2773,30 +2773,33 @@ static int kdf_test_ctrl(EVP_TEST *t, EVP_KDF_CTX *kctx,
if (!TEST_ptr(name = OPENSSL_strdup(value)))
return 0;
p = strchr(name, ':');
- if (p != NULL)
+ if (p == NULL)
+ p = "";
+ else
*p++ = '\0';
rv = OSSL_PARAM_allocate_from_text(kdata->p, defs, name, p,
- p != NULL ? strlen(p) : 0, NULL);
+ strlen(p), NULL);
*++kdata->p = OSSL_PARAM_construct_end();
if (!rv) {
t->err = "KDF_PARAM_ERROR";
OPENSSL_free(name);
return 0;
}
- if (p != NULL && strcmp(name, "digest") == 0) {
+ if (strcmp(name, "digest") == 0) {
if (is_digest_disabled(p)) {
TEST_info("skipping, '%s' is disabled", p);
t->skip = 1;
}
}
- if (p != NULL
- && (strcmp(name, "cipher") == 0
- || strcmp(name, "cekalg") == 0)
+
+ if ((strcmp(name, "cipher") == 0
+ || strcmp(name, "cekalg") == 0)
&& is_cipher_disabled(p)) {
TEST_info("skipping, '%s' is disabled", p);
t->skip = 1;
}
+
OPENSSL_free(name);
return 1;
}