Fix threading issue that at best will leak memory
authorPauli <paul.dale@oracle.com>
Fri, 3 Jun 2016 14:52:32 +0000 (10:52 -0400)
committerRich Salz <rsalz@openssl.org>
Fri, 3 Jun 2016 16:08:13 +0000 (12:08 -0400)
The problem is the checking in policy_cache_set, there is a race
condition between the null check and obtaining the lock.  The fix is in
policy_cache_new to detect if the creation has happened already.

Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/x509v3/pcy_cache.c

index e254142c0f6af7a31763b8d535210224ce81510c..a9ee30a8d9135636020d5cef7ee3e8e4f6818b09 100644 (file)
@@ -78,6 +78,9 @@ static int policy_cache_new(X509 *x)
     CERTIFICATEPOLICIES *ext_cpols = NULL;
     POLICY_MAPPINGS *ext_pmaps = NULL;
     int i;
     CERTIFICATEPOLICIES *ext_cpols = NULL;
     POLICY_MAPPINGS *ext_pmaps = NULL;
     int i;
+
+    if (x->policy_cache != NULL)
+        return 1;
     cache = OPENSSL_malloc(sizeof(*cache));
     if (cache == NULL)
         return 0;
     cache = OPENSSL_malloc(sizeof(*cache));
     if (cache == NULL)
         return 0;