summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitezslav Cizek <vcizek@suse.com>2016-11-24 13:21:41 +0100
committerRich Salz <rsalz@openssl.org>2016-11-26 20:09:12 -0500
commit4675a56a3ce2bef715386e45036426c8a4329d39 (patch)
tree97fbde62e3be07c4b1d74c356eaedc1a12b7c5d4
parentedfca4e3daab653ec6db79ef1b01762db7ba1a52 (diff)
apps/speed.c: Fix crash when config loading failsOpenSSL_1_0_1-stable
Move rsa_key initialization in front of load_config(). If loading the config fails, rsa_key isn't initialized and may cause invalid free() in the end: cleanup. Remove superfluous memset. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit c003851783ed05e3fd5296786e1f8f6a63dc4f31)
-rw-r--r--apps/speed.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/apps/speed.c b/apps/speed.c
index ef72723036..7922473504 100644
--- a/apps/speed.c
+++ b/apps/speed.c
@@ -666,6 +666,10 @@ int MAIN(int argc, char **argv)
ecdh_b[i] = NULL;
}
# endif
+# ifndef OPENSSL_NO_RSA
+ for (i = 0; i < RSA_NUM; i++)
+ rsa_key[i] = NULL;
+# endif
if (bio_err == NULL)
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
@@ -674,12 +678,6 @@ int MAIN(int argc, char **argv)
if (!load_config(bio_err, NULL))
goto end;
-# ifndef OPENSSL_NO_RSA
- memset(rsa_key, 0, sizeof(rsa_key));
- for (i = 0; i < RSA_NUM; i++)
- rsa_key[i] = NULL;
-# endif
-
if ((buf = (unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL) {
BIO_printf(bio_err, "out of memory\n");
goto end;