Title: [218523] trunk/Source/WebCore
Revision
218523
Author
commit-qu...@webkit.org
Date
2017-06-19 18:47:00 -0700 (Mon, 19 Jun 2017)

Log Message

[cURL] Move file scope static variables into function scopes
https://bugs.webkit.org/show_bug.cgi?id=173567

Patch by Daewoong Jang <daewoong.j...@navercorp.com> on 2017-06-19
Reviewed by Alex Christensen.

* platform/network/curl/SSLHandle.cpp:
(WebCore::allowedHosts):
(WebCore::allowedClientHosts):
(WebCore::allowsAnyHTTPSCertificateHosts):
(WebCore::addAllowedClientCertificate):
(WebCore::setSSLClientCertificate):
(WebCore::sslIgnoreHTTPSCertificate):
(WebCore::certVerifyCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218522 => 218523)


--- trunk/Source/WebCore/ChangeLog	2017-06-20 01:23:34 UTC (rev 218522)
+++ trunk/Source/WebCore/ChangeLog	2017-06-20 01:47:00 UTC (rev 218523)
@@ -1,3 +1,19 @@
+2017-06-19  Daewoong Jang  <daewoong.j...@navercorp.com>
+
+        [cURL] Move file scope static variables into function scopes
+        https://bugs.webkit.org/show_bug.cgi?id=173567
+
+        Reviewed by Alex Christensen.
+
+        * platform/network/curl/SSLHandle.cpp:
+        (WebCore::allowedHosts):
+        (WebCore::allowedClientHosts):
+        (WebCore::allowsAnyHTTPSCertificateHosts):
+        (WebCore::addAllowedClientCertificate):
+        (WebCore::setSSLClientCertificate):
+        (WebCore::sslIgnoreHTTPSCertificate):
+        (WebCore::certVerifyCallback):
+
 2017-06-19  Darin Adler  <da...@apple.com>
 
         [Cocoa] implement URLSession:task:needNewBodyStream: delegate method

Modified: trunk/Source/WebCore/platform/network/curl/SSLHandle.cpp (218522 => 218523)


--- trunk/Source/WebCore/platform/network/curl/SSLHandle.cpp	2017-06-20 01:23:34 UTC (rev 218522)
+++ trunk/Source/WebCore/platform/network/curl/SSLHandle.cpp	2017-06-20 01:47:00 UTC (rev 218523)
@@ -35,31 +35,42 @@
 #include <openssl/ssl.h>
 #include <openssl/x509_vfy.h>
 #include <wtf/ListHashSet.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/text/CString.h>
 
 namespace WebCore {
 
 typedef std::tuple<String, String> clientCertificate;
-static HashMap<String, ListHashSet<String>, ASCIICaseInsensitiveHash> allowedHosts;
-static HashMap<String, clientCertificate, ASCIICaseInsensitiveHash> allowedClientHosts;
 
+static HashMap<String, ListHashSet<String>, ASCIICaseInsensitiveHash>& allowedHosts()
+{
+    static NeverDestroyed<HashMap<String, ListHashSet<String>, ASCIICaseInsensitiveHash>> map;
+    return map;
+}
+
+static HashMap<String, clientCertificate, ASCIICaseInsensitiveHash>& allowedClientHosts()
+{
+    static NeverDestroyed<HashMap<String, clientCertificate, ASCIICaseInsensitiveHash>> map;
+    return map;
+}
+
 void allowsAnyHTTPSCertificateHosts(const String& host)
 {
     ListHashSet<String> certificates;
-    allowedHosts.set(host, certificates);
+    allowedHosts().set(host, certificates);
 }
 
 void addAllowedClientCertificate(const String& host, const String& certificate, const String& key)
 {
     clientCertificate clientInfo(certificate, key);
-    allowedClientHosts.set(host, clientInfo);
+    allowedClientHosts().set(host, clientInfo);
 }
 
 void setSSLClientCertificate(ResourceHandle* handle)
 {
     String host = handle->firstRequest().url().host();
-    auto it = allowedClientHosts.find(host);
-    if (it == allowedClientHosts.end())
+    auto it = allowedClientHosts().find(host);
+    if (it == allowedClientHosts().end())
         return;
 
     ResourceHandleInternal* d = handle->getInternal();
@@ -71,8 +82,8 @@
 
 bool sslIgnoreHTTPSCertificate(const String& host, const ListHashSet<String>& certificates)
 {
-    auto it = allowedHosts.find(host);
-    if (it != allowedHosts.end()) {
+    auto it = allowedHosts().find(host);
+    if (it != allowedHosts().end()) {
         if ((it->value).isEmpty()) {
             it->value = certificates;
             return true;
@@ -198,8 +209,8 @@
     d->m_sslErrors = sslCertificateFlag(err);
 
 #if PLATFORM(WIN)
-    auto it = allowedHosts.find(host);
-    ok = (it != allowedHosts.end());
+    auto it = allowedHosts().find(host);
+    ok = (it != allowedHosts().end());
 #else
     ListHashSet<String> certificates;
     if (!pemData(ctx, certificates))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to