Skip to content

Commit

Permalink
Fix up path generation to use OPENSSL_MODULES
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #24025)

(cherry picked from commit 4e3c1e6)
  • Loading branch information
nhorman authored and t8m committed Apr 18, 2024
1 parent aa42bd3 commit e21980f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 5 additions & 4 deletions crypto/provider_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,18 @@ 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 (!ossl_provider_set_module_path(prov, template.path)) {
ossl_provider_free(prov);
return NULL;
}

if (params != NULL) /* We copied the parameters, let's free them */
sk_INFOPAIR_pop_free(template.parameters, infopair_free);

if (prov == NULL)
return NULL;

if (!ossl_provider_set_module_path(prov, template.path)) {
ossl_provider_free(prov);
return NULL;
}

prov->libctx = libctx;
#ifndef FIPS_MODULE
prov->error_lib = ERR_get_next_error_library();
Expand Down
15 changes: 14 additions & 1 deletion test/prov_config_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e21980f

Please sign in to comment.