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

5c1a6c
diff -up openssl-1.0.1e/crypto/asn1/x_x509.c.use-after-free openssl-1.0.1e/crypto/asn1/x_x509.c
5c1a6c
--- openssl-1.0.1e/crypto/asn1/x_x509.c.use-after-free	2013-02-11 16:26:04.000000000 +0100
5c1a6c
+++ openssl-1.0.1e/crypto/asn1/x_x509.c	2015-06-11 11:14:52.581856349 +0200
5c1a6c
@@ -170,8 +170,14 @@ X509 *d2i_X509_AUX(X509 **a, const unsig
5c1a6c
 {
5c1a6c
 	const unsigned char *q;
5c1a6c
 	X509 *ret;
5c1a6c
+	int freeret = 0;
5c1a6c
+
5c1a6c
 	/* Save start position */
5c1a6c
 	q = *pp;
5c1a6c
+
5c1a6c
+	if(!a || *a == NULL) {
5c1a6c
+		freeret = 1;
5c1a6c
+	}
5c1a6c
 	ret = d2i_X509(a, pp, length);
5c1a6c
 	/* If certificate unreadable then forget it */
5c1a6c
 	if(!ret) return NULL;
5c1a6c
@@ -181,7 +187,11 @@ X509 *d2i_X509_AUX(X509 **a, const unsig
5c1a6c
 	if(!d2i_X509_CERT_AUX(&ret->aux, pp, length)) goto err;
5c1a6c
 	return ret;
5c1a6c
 	err:
5c1a6c
-	X509_free(ret);
5c1a6c
+	if(freeret) {
5c1a6c
+		X509_free(ret);
5c1a6c
+		if (a)
5c1a6c
+			*a = NULL;
5c1a6c
+	}
5c1a6c
 	return NULL;
5c1a6c
 }
5c1a6c
 
96beb5
diff -up openssl-1.0.1e/crypto/ec/ec_asn1.c.use-after-free openssl-1.0.1e/crypto/ec/ec_asn1.c
5c1a6c
--- openssl-1.0.1e/crypto/ec/ec_asn1.c.use-after-free	2013-02-11 16:26:04.000000000 +0100
5c1a6c
+++ openssl-1.0.1e/crypto/ec/ec_asn1.c	2015-06-11 11:14:52.581856349 +0200
96beb5
@@ -1140,8 +1140,6 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, con
96beb5
                                  ERR_R_MALLOC_FAILURE);
96beb5
 			goto err;
96beb5
 			}
96beb5
-		if (a)
96beb5
-			*a = ret;
96beb5
 		}
96beb5
 	else
96beb5
 		ret = *a;
96beb5
@@ -1206,11 +1204,13 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, con
96beb5
 			}
96beb5
 		}
96beb5
 
96beb5
+	if (a)
96beb5
+		*a = ret;
96beb5
 	ok = 1;
96beb5
 err:
96beb5
 	if (!ok)
96beb5
 		{
96beb5
-		if (ret)
96beb5
+		if (ret && (a == NULL || *a != ret))
96beb5
 			EC_KEY_free(ret);
96beb5
 		ret = NULL;
96beb5
 		}
5c1a6c
@@ -1358,8 +1358,6 @@ EC_KEY *d2i_ECParameters(EC_KEY **a, con
5c1a6c
 			ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_MALLOC_FAILURE);
5c1a6c
 			return NULL;
5c1a6c
 			}
5c1a6c
-		if (a)
5c1a6c
-			*a = ret;
5c1a6c
 		}
5c1a6c
 	else
5c1a6c
 		ret = *a;
5c1a6c
@@ -1367,9 +1365,14 @@ EC_KEY *d2i_ECParameters(EC_KEY **a, con
5c1a6c
 	if (!d2i_ECPKParameters(&ret->group, in, len))
5c1a6c
 		{
5c1a6c
 		ECerr(EC_F_D2I_ECPARAMETERS, ERR_R_EC_LIB);
5c1a6c
+		if (a == NULL || *a != ret)
5c1a6c
+			EC_KEY_free(ret);
5c1a6c
 		return NULL;
5c1a6c
 		}
5c1a6c
 
5c1a6c
+	if (a)
5c1a6c
+		*a = ret;
5c1a6c
+
5c1a6c
 	return ret;
5c1a6c
 	}
5c1a6c