diff options
author | Matt Caswell <matt@openssl.org> | 2016-05-23 11:55:54 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-24 00:30:24 +0200 |
commit | dae00d631fdaed48d88c454864abbd6ce99c63d6 (patch) | |
tree | c1653e169ee174f1ad7a7a252134672e48398329 /crypto/conf | |
parent | Use strerror_r()/strerror_s() instead of strerror() where possible (diff) | |
download | openssl-dae00d631fdaed48d88c454864abbd6ce99c63d6.tar.xz openssl-dae00d631fdaed48d88c454864abbd6ce99c63d6.zip |
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')
-rw-r--r-- | crypto/conf/conf_lib.c | 16 |
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 |