]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix up path generation to use OPENSSL_MODULES
authorNeil Horman <nhorman@openssl.org>
Fri, 5 Apr 2024 13:06:10 +0000 (09:06 -0400)
committerTomas Mraz <tomas@openssl.org>
Fri, 26 Apr 2024 12:04:25 +0000 (14:04 +0200)
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)

crypto/provider_core.c
test/prov_config_test.c

index 07b63c45ba3c4c017ed1a6b6b458b6774c2c7c38..9f8e73c9d0e7d1f6112602160a7a8941bd7c9253 100644 (file)
@@ -560,6 +560,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;
index 2fac741a3dc994d72c51fe3d0a347d27d55d2963..fee2dffdb206ec2119c0384f2c48b33f2be894fd 100644 (file)
@@ -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))