Blame SOURCES/openssl-1.0.1e-cve-2015-1790.patch

5c1a6c
diff -up openssl-1.0.1e/crypto/pkcs7/pk7_doit.c.missing-content openssl-1.0.1e/crypto/pkcs7/pk7_doit.c
5c1a6c
--- openssl-1.0.1e/crypto/pkcs7/pk7_doit.c.missing-content	2015-05-25 12:03:41.000000000 +0200
5c1a6c
+++ openssl-1.0.1e/crypto/pkcs7/pk7_doit.c	2015-06-09 15:21:21.377951520 +0200
5c1a6c
@@ -472,6 +472,12 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE
5c1a6c
 	switch (i)
5c1a6c
 		{
5c1a6c
 	case NID_pkcs7_signed:
5c1a6c
+		/*
5c1a6c
+		 * p7->d.sign->contents is a PKCS7 structure consisting of a contentType
5c1a6c
+		 * field and optional content.
5c1a6c
+		 * data_body is NULL if that structure has no (=detached) content
5c1a6c
+		 * or if the contentType is wrong (i.e., not "data").
5c1a6c
+		 */
5c1a6c
 		data_body=PKCS7_get_octet_string(p7->d.sign->contents);
5c1a6c
 		if (!PKCS7_is_detached(p7) && data_body == NULL)
5c1a6c
 			{
5c1a6c
@@ -484,6 +490,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE
5c1a6c
 	case NID_pkcs7_signedAndEnveloped:
5c1a6c
 		rsk=p7->d.signed_and_enveloped->recipientinfo;
5c1a6c
 		md_sk=p7->d.signed_and_enveloped->md_algs;
5c1a6c
+		/* data_body is NULL if the optional EncryptedContent is missing. */
5c1a6c
 		data_body=p7->d.signed_and_enveloped->enc_data->enc_data;
5c1a6c
 		enc_alg=p7->d.signed_and_enveloped->enc_data->algorithm;
5c1a6c
 		evp_cipher=EVP_get_cipherbyobj(enc_alg->algorithm);
5c1a6c
@@ -496,6 +503,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE
5c1a6c
 	case NID_pkcs7_enveloped:
5c1a6c
 		rsk=p7->d.enveloped->recipientinfo;
5c1a6c
 		enc_alg=p7->d.enveloped->enc_data->algorithm;
5c1a6c
+		/* data_body is NULL if the optional EncryptedContent is missing. */
5c1a6c
 		data_body=p7->d.enveloped->enc_data->enc_data;
5c1a6c
 		evp_cipher=EVP_get_cipherbyobj(enc_alg->algorithm);
5c1a6c
 		if (evp_cipher == NULL)
5c1a6c
@@ -509,6 +517,13 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE
5c1a6c
 	        goto err;
5c1a6c
 		}
5c1a6c
 
5c1a6c
+	/* Detached content must be supplied via in_bio instead. */
5c1a6c
+	if (data_body == NULL && in_bio == NULL)
5c1a6c
+		{
5c1a6c
+		PKCS7err(PKCS7_F_PKCS7_DATADECODE, PKCS7_R_NO_CONTENT);
5c1a6c
+		goto err;
5c1a6c
+		}
5c1a6c
+
5c1a6c
 	/* We will be checking the signature */
5c1a6c
 	if (md_sk != NULL)
5c1a6c
 		{
5c1a6c
@@ -665,7 +680,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKE
5c1a6c
 		}
5c1a6c
 
5c1a6c
 #if 1
5c1a6c
-	if (PKCS7_is_detached(p7) || (in_bio != NULL))
5c1a6c
+	if (in_bio != NULL)
5c1a6c
 		{
5c1a6c
 		bio=in_bio;
5c1a6c
 		}