CONF_modules_load_file_ex(): Do not try to load an empty file name

Fixes #21258

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/21282)
This commit is contained in:
Tomas Mraz 2023-06-26 11:11:57 +02:00
parent 2c59d54cd7
commit 8b7d5ea7dd

View File

@ -184,15 +184,21 @@ int CONF_modules_load_file_ex(OSSL_LIB_CTX *libctx, const char *filename,
CONF *conf = NULL;
int ret = 0, diagnostics = 0;
ERR_set_mark();
if (filename == NULL) {
file = CONF_get1_default_config_file();
if (file == NULL)
goto err;
if (*file == '\0') {
/* Do not try to load an empty file name but do not error out */
ret = 1;
goto err;
}
} else {
file = (char *)filename;
}
ERR_set_mark();
conf = NCONF_new_ex(libctx, NULL);
if (conf == NULL)
goto err;