Title: [227575] trunk/Source/WebCore
- Revision
- 227575
- Author
- commit-qu...@webkit.org
- Date
- 2018-01-24 14:43:11 -0800 (Wed, 24 Jan 2018)
Log Message
[Curl] Allocate CurlSSLVerifier only when it is required.
https://bugs.webkit.org/show_bug.cgi?id=182061
CurlSSLVerifier was a member function of CurlRequest. This patch do
lazy initialization of it only when actually it is required.
Also configuration method is not required by moving those stuff to
constructor of SSLVerifier which makes much safer because there's
no change to change its behavior from outside.
Patch by Basuke Suzuki <basuke.suz...@sony.com> on 2018-01-24
Reviewed by Alex Christensen.
* platform/network/curl/CurlRequest.cpp:
(WebCore::CurlRequest::willSetupSslCtx):
(WebCore::CurlRequest::didCompleteTransfer):
(WebCore::CurlRequest::finalizeTransfer):
* platform/network/curl/CurlRequest.h:
* platform/network/curl/CurlSSLVerifier.cpp:
(WebCore::CurlSSLVerifier::CurlSSLVerifier):
(WebCore::CurlSSLVerifier::setSslCtx): Deleted.
* platform/network/curl/CurlSSLVerifier.h:
(WebCore::CurlSSLVerifier::setCurlHandle): Deleted.
(WebCore::CurlSSLVerifier::setHostName): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (227574 => 227575)
--- trunk/Source/WebCore/ChangeLog 2018-01-24 22:39:18 UTC (rev 227574)
+++ trunk/Source/WebCore/ChangeLog 2018-01-24 22:43:11 UTC (rev 227575)
@@ -1,3 +1,28 @@
+2018-01-24 Basuke Suzuki <basuke.suz...@sony.com>
+
+ [Curl] Allocate CurlSSLVerifier only when it is required.
+ https://bugs.webkit.org/show_bug.cgi?id=182061
+
+ CurlSSLVerifier was a member function of CurlRequest. This patch do
+ lazy initialization of it only when actually it is required.
+ Also configuration method is not required by moving those stuff to
+ constructor of SSLVerifier which makes much safer because there's
+ no change to change its behavior from outside.
+
+ Reviewed by Alex Christensen.
+
+ * platform/network/curl/CurlRequest.cpp:
+ (WebCore::CurlRequest::willSetupSslCtx):
+ (WebCore::CurlRequest::didCompleteTransfer):
+ (WebCore::CurlRequest::finalizeTransfer):
+ * platform/network/curl/CurlRequest.h:
+ * platform/network/curl/CurlSSLVerifier.cpp:
+ (WebCore::CurlSSLVerifier::CurlSSLVerifier):
+ (WebCore::CurlSSLVerifier::setSslCtx): Deleted.
+ * platform/network/curl/CurlSSLVerifier.h:
+ (WebCore::CurlSSLVerifier::setCurlHandle): Deleted.
+ (WebCore::CurlSSLVerifier::setHostName): Deleted.
+
2018-01-24 Antti Koivisto <an...@apple.com>
Assertion failure in RenderMultiColumnSet::requiresBalancing() on fast/multicol/spanner-crash-when-adding-summary.html
Modified: trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp (227574 => 227575)
--- trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp 2018-01-24 22:39:18 UTC (rev 227574)
+++ trunk/Source/WebCore/platform/network/curl/CurlRequest.cpp 2018-01-24 22:43:11 UTC (rev 227575)
@@ -232,9 +232,7 @@
CURLcode CurlRequest::willSetupSslCtx(void* sslCtx)
{
- m_sslVerifier.setCurlHandle(m_curlHandle.get());
- m_sslVerifier.setHostName(m_request.url().host());
- m_sslVerifier.setSslCtx(sslCtx);
+ m_sslVerifier = std::make_unique<CurlSSLVerifier>(m_curlHandle.get(), m_request.url().host(), sslCtx);
return CURLE_OK;
}
@@ -427,8 +425,8 @@
} else {
auto type = (result == CURLE_OPERATION_TIMEDOUT && m_request.timeoutInterval() > 0.0) ? ResourceError::Type::Timeout : ResourceError::Type::General;
auto resourceError = ResourceError::httpError(result, m_request.url(), type);
- if (m_sslVerifier.sslErrors())
- resourceError.setSslErrors(m_sslVerifier.sslErrors());
+ if (m_sslVerifier && m_sslVerifier->sslErrors())
+ resourceError.setSslErrors(m_sslVerifier->sslErrors());
finalizeTransfer();
callClient([error = resourceError.isolatedCopy()](CurlRequestClient& client) {
@@ -447,6 +445,7 @@
{
closeDownloadFile();
m_formDataStream.clean();
+ m_sslVerifier = nullptr;
m_multipartHandle = nullptr;
m_curlHandle = nullptr;
}
Modified: trunk/Source/WebCore/platform/network/curl/CurlRequest.h (227574 => 227575)
--- trunk/Source/WebCore/platform/network/curl/CurlRequest.h 2018-01-24 22:39:18 UTC (rev 227574)
+++ trunk/Source/WebCore/platform/network/curl/CurlRequest.h 2018-01-24 22:43:11 UTC (rev 227575)
@@ -157,7 +157,7 @@
std::unique_ptr<CurlHandle> m_curlHandle;
CurlFormDataStream m_formDataStream;
- CurlSSLVerifier m_sslVerifier;
+ std::unique_ptr<CurlSSLVerifier> m_sslVerifier;
std::unique_ptr<CurlMultipartHandle> m_multipartHandle;
CurlResponse m_response;
Modified: trunk/Source/WebCore/platform/network/curl/CurlSSLVerifier.cpp (227574 => 227575)
--- trunk/Source/WebCore/platform/network/curl/CurlSSLVerifier.cpp 2018-01-24 22:39:18 UTC (rev 227574)
+++ trunk/Source/WebCore/platform/network/curl/CurlSSLVerifier.cpp 2018-01-24 22:43:11 UTC (rev 227575)
@@ -34,13 +34,14 @@
namespace WebCore {
-void CurlSSLVerifier::setSslCtx(void* sslCtx)
+CurlSSLVerifier::CurlSSLVerifier(CurlHandle* curlHandle, const String& hostName, void* sslCtx)
+ : m_curlHandle(curlHandle)
+ , m_hostName(hostName)
{
- if (!sslCtx)
- return;
-
- SSL_CTX_set_app_data(static_cast<SSL_CTX*>(sslCtx), this);
- SSL_CTX_set_verify(static_cast<SSL_CTX*>(sslCtx), SSL_VERIFY_PEER, certVerifyCallback);
+ if (sslCtx) {
+ SSL_CTX_set_app_data(static_cast<SSL_CTX*>(sslCtx), this);
+ SSL_CTX_set_verify(static_cast<SSL_CTX*>(sslCtx), SSL_VERIFY_PEER, certVerifyCallback);
+ }
}
int CurlSSLVerifier::certVerifyCallback(int ok, X509_STORE_CTX* storeCtx)
Modified: trunk/Source/WebCore/platform/network/curl/CurlSSLVerifier.h (227574 => 227575)
--- trunk/Source/WebCore/platform/network/curl/CurlSSLVerifier.h 2018-01-24 22:39:18 UTC (rev 227574)
+++ trunk/Source/WebCore/platform/network/curl/CurlSSLVerifier.h 2018-01-24 22:43:11 UTC (rev 227575)
@@ -50,12 +50,8 @@
SSL_CERTIFICATE_GENERIC_ERROR = (1 << 6) // Some other error occurred validating the certificate
};
- CurlSSLVerifier() = default;
+ CurlSSLVerifier(CurlHandle*, const String& hostName, void* sslCtx);
- void setCurlHandle(CurlHandle* curlHandle) { m_curlHandle = curlHandle; }
- void setHostName(const String& hostName) { m_hostName = hostName; }
- void setSslCtx(void*);
-
int sslErrors() { return m_sslErrors; }
private:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes