Use OPENSSL_strdup() for strings freed by OPENSSL_free()

Things can get messy when application decides to use it's own memory
allocation functions using CRYPTO_set_mem_functions(3ossl)

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27163)
This commit is contained in:
sashan 2025-03-26 09:37:01 +01:00 committed by Tomas Mraz
parent 50f945117c
commit 7fa51041e4
2 changed files with 2 additions and 2 deletions

View File

@ -127,7 +127,7 @@ static int set_random_provider_name(RAND_GLOBAL *dgbl, const char *name)
return 1;
OPENSSL_free(dgbl->random_provider_name);
dgbl->random_provider_name = strdup(name);
dgbl->random_provider_name = OPENSSL_strdup(name);
return dgbl->random_provider_name != NULL;
}

View File

@ -59,7 +59,7 @@ static char *change_path(const char *file)
ret = chdir(s);
if (ret == 0)
new_config_name = strdup(last + DIRSEP_PRESERVE + 1);
new_config_name = OPENSSL_strdup(last + DIRSEP_PRESERVE + 1);
err:
OPENSSL_free(s);
return new_config_name;