From: lteo Date: Fri, 18 Apr 2014 18:08:36 +0000 (+0000) Subject: Use the cleaned up asprintf-based make_config_name() to make the name of X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c7e9642196d6e0737e62873a1b6e88861d5a243c;p=openbsd Use the cleaned up asprintf-based make_config_name() to make the name of the config file instead of the malloc/BUF_strlcpy/BUF_strlcat calls with no return value checks (that make_config_name() also used to do prior to being cleaned up). ok beck@ --- diff --git a/lib/libssl/src/apps/ca.c b/lib/libssl/src/apps/ca.c index f7b73189de0..1d750187324 100644 --- a/lib/libssl/src/apps/ca.c +++ b/lib/libssl/src/apps/ca.c @@ -91,7 +91,6 @@ #define BASE_SECTION "ca" -#define CONFIG_FILE "openssl.cnf" #define ENV_DEFAULT_CA "default_ca" @@ -539,14 +538,10 @@ ca_main(int argc, char **argv) if (configfile == NULL) configfile = getenv("SSLEAY_CONF"); if (configfile == NULL) { - const char *s = X509_get_default_cert_area(); - size_t len; - - len = strlen(s) + sizeof(CONFIG_FILE) + 1; - tofree = malloc(len); - BUF_strlcpy(tofree, s, len); - BUF_strlcat(tofree, "/", len); - BUF_strlcat(tofree, CONFIG_FILE, len); + if ((tofree = make_config_name()) == NULL) { + BIO_printf(bio_err, "error making config file name\n"); + goto err; + } configfile = tofree; } BIO_printf(bio_err, "Using configuration from %s\n", configfile); diff --git a/lib/libssl/src/apps/srp.c b/lib/libssl/src/apps/srp.c index a7bdcef0c99..bdd3017251d 100644 --- a/lib/libssl/src/apps/srp.c +++ b/lib/libssl/src/apps/srp.c @@ -72,7 +72,6 @@ #define BASE_SECTION "srp" -#define CONFIG_FILE "openssl.cnf" #define ENV_RANDFILE "RANDFILE" @@ -413,14 +412,10 @@ srp_main(int argc, char **argv) if (configfile == NULL) configfile = getenv("SSLEAY_CONF"); if (configfile == NULL) { - const char *s = X509_get_default_cert_area(); - size_t len; - - len = strlen(s) + sizeof(CONFIG_FILE) + 1; - tofree = malloc(len); - BUF_strlcpy(tofree, s, len); - BUF_strlcat(tofree, "/", len); - BUF_strlcat(tofree, CONFIG_FILE, len); + if ((tofree = make_config_name()) == NULL) { + BIO_printf(bio_err, "error making config file name\n"); + goto err; + } configfile = tofree; } VERBOSE BIO_printf(bio_err, "Using configuration from %s\n", configfile);