summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Horman <nhorman@openssl.org>2024-04-05 09:06:10 -0400
committerTomas Mraz <tomas@openssl.org>2024-04-26 14:06:33 +0200
commit25e1d8dcdedaa0e99218b4dd24f82a11f2a470eb (patch)
treeb83a5cab6a73d3fd2643b9860996550030553c2e
parentf663322bd61312a07d678fe3b22e517180653a37 (diff)
Fix up path generation to use OPENSSL_MODULES
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (cherry picked from commit 4e3c1e6206251c59855362d6d2edab4621c31dec) (Merged from https://github.com/openssl/openssl/pull/24198) (cherry picked from commit 163202f0b95cfc7e666e45cafc55a505f51f6153)
-rw-r--r--crypto/provider_core.c4
-rw-r--r--test/prov_config_test.c15
2 files changed, 18 insertions, 1 deletions
diff --git a/crypto/provider_core.c b/crypto/provider_core.c
index fb93f9fbe0..4fccac7ab5 100644
--- a/crypto/provider_core.c
+++ b/crypto/provider_core.c
@@ -568,6 +568,10 @@ OSSL_PROVIDER *ossl_provider_new(OSSL_LIB_CTX *libctx, const char *name,
/* provider_new() generates an error, so no need here */
prov = provider_new(name, template.init, template.parameters);
+
+ if (prov == NULL)
+ return NULL;
+
if (!ossl_provider_set_module_path(prov, template.path)) {
ossl_provider_free(prov);
return NULL;
diff --git a/test/prov_config_test.c b/test/prov_config_test.c
index 2fac741a3d..fee2dffdb2 100644
--- a/test/prov_config_test.c
+++ b/test/prov_config_test.c
@@ -72,14 +72,27 @@ static int test_recursive_config(void)
return testresult;
}
+#define P_TEST_PATH "/../test/p_test.so"
static int test_path_config(void)
{
OSSL_LIB_CTX *ctx = NULL;
OSSL_PROVIDER *prov;
int testresult = 0;
struct stat sbuf;
+ char *module_path = getenv("OPENSSL_MODULES");
+ char *full_path = NULL;
+ int rc;
- if (stat("../test/p_test.so", &sbuf) == -1)
+ full_path = OPENSSL_zalloc(strlen(module_path) + strlen(P_TEST_PATH) + 1);
+ if (!TEST_ptr(full_path))
+ return 0;
+
+ strcpy(full_path, module_path);
+ full_path = strcat(full_path, P_TEST_PATH);
+ TEST_info("full path is %s", full_path);
+ rc = stat(full_path, &sbuf);
+ OPENSSL_free(full_path);
+ if (rc == -1)
return TEST_skip("Skipping modulepath test as provider not present");
if (!TEST_ptr(pathedconfig))