Blame SOURCES/openssl-fips-0.9.8e-cve-2011-4109.patch

5820f5
diff -up openssl-fips-0.9.8e/CHANGES.doublefree openssl-fips-0.9.8e/CHANGES
5820f5
diff -up openssl-fips-0.9.8e/crypto/x509v3/pcy_map.c.doublefree openssl-fips-0.9.8e/crypto/x509v3/pcy_map.c
5820f5
--- openssl-fips-0.9.8e/crypto/x509v3/pcy_map.c.doublefree	2004-03-25 14:45:58.000000000 +0100
5820f5
+++ openssl-fips-0.9.8e/crypto/x509v3/pcy_map.c	2012-01-16 10:37:18.480935735 +0100
5820f5
@@ -70,8 +70,6 @@ static int ref_cmp(const X509_POLICY_REF
5820f5
 
5820f5
 static void policy_map_free(X509_POLICY_REF *map)
5820f5
 	{
5820f5
-	if (map->subjectDomainPolicy)
5820f5
-		ASN1_OBJECT_free(map->subjectDomainPolicy);
5820f5
 	OPENSSL_free(map);
5820f5
 	}
5820f5
 
5820f5
@@ -95,6 +93,7 @@ int policy_cache_set_mapping(X509 *x, PO
5820f5
 	{
5820f5
 	POLICY_MAPPING *map;
5820f5
 	X509_POLICY_REF *ref = NULL;
5820f5
+	ASN1_OBJECT *subjectDomainPolicyRef;
5820f5
 	X509_POLICY_DATA *data;
5820f5
 	X509_POLICY_CACHE *cache = x->policy_cache;
5820f5
 	int i;
5820f5
@@ -153,13 +152,16 @@ int policy_cache_set_mapping(X509 *x, PO
5820f5
 		if (!sk_ASN1_OBJECT_push(data->expected_policy_set, 
5820f5
 						map->subjectDomainPolicy))
5820f5
 			goto bad_mapping;
5820f5
+                /* map->subjectDomainPolicy will be freed when
5820f5
+                 * cache->data is freed. Set it to NULL to avoid double-free. */
5820f5
+                subjectDomainPolicyRef = map->subjectDomainPolicy;
5820f5
+                map->subjectDomainPolicy = NULL;
5820f5
 		
5820f5
 		ref = OPENSSL_malloc(sizeof(X509_POLICY_REF));
5820f5
 		if (!ref)
5820f5
 			goto bad_mapping;
5820f5
 
5820f5
-		ref->subjectDomainPolicy = map->subjectDomainPolicy;
5820f5
-		map->subjectDomainPolicy = NULL;
5820f5
+		ref->subjectDomainPolicy = subjectDomainPolicyRef;
5820f5
 		ref->data = data;
5820f5
 
5820f5
 		if (!sk_X509_POLICY_REF_push(cache->maps, ref))
5820f5
diff -up openssl-fips-0.9.8e/crypto/x509v3/pcy_tree.c.doublefree openssl-fips-0.9.8e/crypto/x509v3/pcy_tree.c
5820f5
--- openssl-fips-0.9.8e/crypto/x509v3/pcy_tree.c.doublefree	2006-11-27 14:36:54.000000000 +0100
5820f5
+++ openssl-fips-0.9.8e/crypto/x509v3/pcy_tree.c	2012-01-16 10:37:18.481935777 +0100
5820f5
@@ -610,6 +610,10 @@ int X509_policy_check(X509_POLICY_TREE *
5820f5
 		case 2:
5820f5
 		return 1;
5820f5
 
5820f5
+                /* Some internal error */
5820f5
+		case -1:
5820f5
+		return -1;
5820f5
+
5820f5
 		/* Some internal error */
5820f5
 		case 0:
5820f5
 		return 0;
5820f5
@@ -689,4 +693,3 @@ int X509_policy_check(X509_POLICY_TREE *
5820f5
 	return 0;
5820f5
 
5820f5
 	}
5820f5
-