File openssl-fix_crash_in_openssl_speed.patch of Package compat-openssl098.14113

commit 4675a56a3ce2bef715386e45036426c8a4329d39
Author: Vitezslav Cizek <vcizek@suse.com>
Date:   Thu Nov 24 13:21:41 2016 +0100

    apps/speed.c: Fix crash when config loading fails
    
    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)

Index: openssl-1.0.1i/apps/speed.c
===================================================================
--- openssl-1.0.1i.orig/apps/speed.c	2017-01-31 16:45:06.031387490 +0100
+++ openssl-1.0.1i/apps/speed.c	2017-01-31 16:45:58.780225588 +0100
@@ -647,7 +647,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)
@@ -656,12 +659,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");
openSUSE Build Service is sponsored by