File openssl-CVE-2016-6302.patch of Package compat-openssl098.14113

commit 1bbe48ab149893a78bf99c8eb8895c928900a16f
Author: Dr. Stephen Henson <steve@openssl.org>
Date:   Tue Aug 23 18:14:54 2016 +0100

    Sanity check ticket length.
    
    If a ticket callback changes the HMAC digest to SHA512 the existing
    sanity checks are not sufficient and an attacker could perform a DoS
    attack with a malformed ticket. Add additional checks based on
    HMAC size.
    
    Thanks to Shi Lei for reporting this bug.
    
    CVE-2016-6302
    
    Reviewed-by: Rich Salz <rsalz@openssl.org>
    (cherry picked from commit baaabfd8fdcec04a691695fad9a664bea43202b6)

Index: openssl-0.9.8j/ssl/t1_lib.c
===================================================================
--- openssl-0.9.8j.orig/ssl/t1_lib.c	2016-09-22 17:57:11.192433068 +0200
+++ openssl-0.9.8j/ssl/t1_lib.c	2016-09-22 18:01:03.684139923 +0200
@@ -941,9 +941,7 @@ static int tls_decrypt_ticket(SSL *s, co
 	HMAC_CTX hctx;
 	EVP_CIPHER_CTX ctx;
 	SSL_CTX *tctx = s->initial_ctx;
-	/* Need at least keyname + iv + some encrypted data */
-	if (eticklen < 48)
-		goto tickerr;
+
 	/* Initialize session ticket encryption and HMAC contexts */
 	HMAC_CTX_init(&hctx);
 	EVP_CIPHER_CTX_init(&ctx);
@@ -972,6 +970,14 @@ static int tls_decrypt_ticket(SSL *s, co
 	/* Attempt to process session ticket, first conduct sanity and
  	 * integrity checks on ticket.
  	 */
+
+    /* Sanity check ticket length: must exceed keyname + IV + HMAC */
+    if (eticklen <= 16 + EVP_CIPHER_CTX_iv_length(&ctx) + mlen) {
+        HMAC_CTX_cleanup(&hctx);
+        EVP_CIPHER_CTX_cleanup(&ctx);
+        goto tickerr;
+    }
+
 	mlen = HMAC_size(&hctx);
 	eticklen -= mlen;
 	/* Check HMAC of encrypted ticket */
openSUSE Build Service is sponsored by