Use the cleaned up asprintf-based make_config_name() to make the name of
authorlteo <lteo@openbsd.org>
Fri, 18 Apr 2014 18:08:36 +0000 (18:08 +0000)
committerlteo <lteo@openbsd.org>
Fri, 18 Apr 2014 18:08:36 +0000 (18:08 +0000)
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@

lib/libssl/src/apps/ca.c
lib/libssl/src/apps/srp.c

index f7b7318..1d75018 100644 (file)
@@ -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);
index a7bdcef..bdd3017 100644 (file)
@@ -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);