Blame SOURCES/openssl-fips-0.9.8e-cve-2015-3197.patch

5820f5
diff -up openssl-fips-0.9.8e/ssl/s2_srvr.c.ssl2-ciphers openssl-fips-0.9.8e/ssl/s2_srvr.c
5820f5
--- openssl-fips-0.9.8e/ssl/s2_srvr.c.ssl2-ciphers	2015-04-02 15:33:51.109049368 +0200
5820f5
+++ openssl-fips-0.9.8e/ssl/s2_srvr.c	2016-02-18 19:15:21.164380375 +0100
5820f5
@@ -393,7 +393,7 @@ static int get_client_master_key(SSL *s)
5820f5
 			}
5820f5
 
5820f5
 		cp=ssl2_get_cipher_by_char(p);
5820f5
-		if (cp == NULL)
5820f5
+		if (cp == NULL || sk_SSL_CIPHER_find(s->session->ciphers, cp) < 0)
5820f5
 			{
5820f5
 			ssl2_return_error(s,SSL2_PE_NO_CIPHER);
5820f5
 			SSLerr(SSL_F_GET_CLIENT_MASTER_KEY, SSL_R_NO_CIPHER_MATCH);
5820f5
@@ -692,9 +692,13 @@ static int get_client_hello(SSL *s)
5820f5
 		    prio = cs;
5820f5
 		    allow = cl;
5820f5
 		    }
5820f5
+
5820f5
+		/* Generate list of SSLv2 ciphers shared between client and server */
5820f5
 		for (z=0; z
5820f5
 			{
5820f5
-			if (sk_SSL_CIPHER_find(allow,sk_SSL_CIPHER_value(prio,z)) < 0)
5820f5
+			const SSL_CIPHER *cp = sk_SSL_CIPHER_value(prio, z);
5820f5
+			if ((cp->algorithms & SSL_SSLV2) == 0 ||
5820f5
+				sk_SSL_CIPHER_find(allow,cp) < 0)
5820f5
 				{
5820f5
 				(void)sk_SSL_CIPHER_delete(prio,z);
5820f5
 				z--;
5820f5
@@ -705,6 +709,14 @@ static int get_client_hello(SSL *s)
5820f5
 		    sk_SSL_CIPHER_free(s->session->ciphers);
5820f5
 		    s->session->ciphers = prio;
5820f5
 		    }
5820f5
+
5820f5
+		/* Make sure we have at least one cipher in common */
5820f5
+		if (sk_SSL_CIPHER_num(s->session->ciphers) == 0)
5820f5
+		    {
5820f5
+		    ssl2_return_error(s, SSL2_PE_NO_CIPHER);
5820f5
+		    SSLerr(SSL_F_GET_CLIENT_HELLO, SSL_R_NO_CIPHER_MATCH);
5820f5
+		    return -1;
5820f5
+		    }
5820f5
 		/* s->session->ciphers should now have a list of
5820f5
 		 * ciphers that are on both the client and server.
5820f5
 		 * This list is ordered by the order the client sent