summaryrefslogtreecommitdiffstats
path: root/crypto/conf/conf_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-05-23 10:55:54 +0100
committerMatt Caswell <matt@openssl.org>2016-05-23 23:30:24 +0100
commitdae00d631fdaed48d88c454864abbd6ce99c63d6 (patch)
treec1653e169ee174f1ad7a7a252134672e48398329 /crypto/conf/conf_lib.c
parent7d37818dacc87c21dfc9d2def5014657344875e3 (diff)
Add error return for OPENSSL_INIT_set_config_filename()
The OPENSSL_INIT_set_config_filename() function can fail so ensure that it provides a suitable error code. GitHub Issue #920 Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/conf/conf_lib.c')
-rw-r--r--crypto/conf/conf_lib.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c
index 1b902e2077..a1e42eb7c4 100644
--- a/crypto/conf/conf_lib.c
+++ b/crypto/conf/conf_lib.c
@@ -339,11 +339,21 @@ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void)
#ifndef OPENSSL_NO_STDIO
-void OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
- const char *config_file)
+int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
+ const char *config_file)
{
+ char *new_config_file = NULL;
+
+ if (config_file != NULL) {
+ new_config_file = strdup(config_file);
+ if (new_config_file == NULL)
+ return 0;
+ }
+
free(settings->config_name);
- settings->config_name = config_file == NULL ? NULL : strdup(config_file);
+ settings->config_name = new_config_file;
+
+ return 1;
}
#endif