Changeset 230425 in webkit
- Timestamp:
- Apr 9, 2018 6:56:10 AM (6 years ago)
- Location:
- releases/WebKitGTK/webkit-2.20/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.20/Source/WebCore/ChangeLog
r230417 r230425 1 2018-04-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] NetworkProcess from WebKitGtk+ 2.19.9x SIGSEVs in NetworkStorageSession (secret search callback) 4 https://bugs.webkit.org/show_bug.cgi?id=183346 5 6 Reviewed by Michael Catanzaro. 7 8 This might happen if a request is cancelled right after the password request starts and before it finishes. We 9 should cancel the password search when the network request is cancelled, not only when the NetworkStorageSession 10 is destroyed. 11 12 * platform/network/NetworkStorageSession.h: 13 * platform/network/soup/NetworkStorageSessionSoup.cpp: 14 (WebCore::NetworkStorageSession::~NetworkStorageSession): 15 (WebCore::SecretServiceSearchData::SecretServiceSearchData): Helper struct to keep the request cancellable and 16 completion handler. 17 (WebCore::NetworkStorageSession::getCredentialFromPersistentStorage): Create a SecretServiceSearchData for the 18 request. 19 * platform/network/soup/ResourceHandleSoup.cpp: 20 (WebCore::ResourceHandle::didReceiveAuthenticationChallenge): Pass the request cancellable to 21 NetworkStorageSession::getCredentialFromPersistentStorage(). 22 1 23 2018-03-27 Fujii Hironori <Hironori.Fujii@sony.com> 2 24 -
releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/network/NetworkStorageSession.h
r228621 r230425 122 122 void setCookieStorage(SoupCookieJar*); 123 123 void setCookieObserverHandler(Function<void ()>&&); 124 void getCredentialFromPersistentStorage(const ProtectionSpace&, Function<void (Credential&&)>completionHandler);124 void getCredentialFromPersistentStorage(const ProtectionSpace&, GCancellable*, Function<void (Credential&&)>&& completionHandler); 125 125 void saveCredentialToPersistentStorage(const ProtectionSpace&, const Credential&); 126 126 #elif USE(CURL) … … 159 159 GRefPtr<SoupCookieJar> m_cookieStorage; 160 160 Function<void ()> m_cookieObserverHandler; 161 #if USE(LIBSECRET)162 Function<void (Credential&&)> m_persisentStorageCompletionHandler;163 GRefPtr<GCancellable> m_persisentStorageCancellable;164 #endif165 161 #elif USE(CURL) 166 162 UniqueRef<CookieJarCurl> m_cookieStorage; -
releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
r225192 r230425 62 62 { 63 63 g_signal_handlers_disconnect_matched(m_cookieStorage.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this); 64 65 #if USE(LIBSECRET)66 g_cancellable_cancel(m_persisentStorageCancellable.get());67 #endif68 64 } 69 65 … … 188 184 return "unknown"; 189 185 } 186 187 struct SecretServiceSearchData { 188 SecretServiceSearchData(GCancellable* cancellable, Function<void (Credential&&)>&& completionHandler) 189 : cancellable(cancellable) 190 , completionHandler(WTFMove(completionHandler)) 191 { 192 } 193 194 ~SecretServiceSearchData() = default; 195 196 GRefPtr<GCancellable> cancellable; 197 Function<void (Credential&&)> completionHandler; 198 }; 190 199 #endif // USE(LIBSECRET) 191 200 192 void NetworkStorageSession::getCredentialFromPersistentStorage(const ProtectionSpace& protectionSpace, Function<void (Credential&&)>completionHandler)201 void NetworkStorageSession::getCredentialFromPersistentStorage(const ProtectionSpace& protectionSpace, GCancellable* cancellable, Function<void (Credential&&)>&& completionHandler) 193 202 { 194 203 #if USE(LIBSECRET) … … 216 225 } 217 226 218 m_persisentStorageCancellable = adoptGRef(g_cancellable_new()); 219 m_persisentStorageCompletionHandler = WTFMove(completionHandler); 227 auto data = std::make_unique<SecretServiceSearchData>(cancellable, WTFMove(completionHandler)); 220 228 secret_service_search(nullptr, SECRET_SCHEMA_COMPAT_NETWORK, attributes.get(), 221 static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS), m_persisentStorageCancellable.get(),229 static_cast<SecretSearchFlags>(SECRET_SEARCH_UNLOCK | SECRET_SEARCH_LOAD_SECRETS), cancellable, 222 230 [](GObject* source, GAsyncResult* result, gpointer userData) { 231 auto data = std::unique_ptr<SecretServiceSearchData>(static_cast<SecretServiceSearchData*>(userData)); 223 232 GUniqueOutPtr<GError> error; 224 233 GUniquePtr<GList> elements(secret_service_search_finish(SECRET_SERVICE(source), result, &error.outPtr())); 225 if (g_error_matches (error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED)) 226 return; 227 228 NetworkStorageSession* session = static_cast<NetworkStorageSession*>(userData); 229 auto completionHandler = std::exchange(session->m_persisentStorageCompletionHandler, nullptr); 230 if (error || !elements || !elements->data) { 231 completionHandler({ }); 234 if (g_cancellable_is_cancelled(data->cancellable.get()) || error || !elements || !elements->data) { 235 data->completionHandler({ }); 232 236 return; 233 237 } 234 238 235 GRefPtr<SecretItem> secretItem = adoptGRef(static_cast<SecretItem*>(elements->data)); 239 GRefPtr<SecretItem> secretItem = static_cast<SecretItem*>(elements->data); 240 g_list_foreach(elements.get(), reinterpret_cast<GFunc>(g_object_unref), nullptr); 236 241 GRefPtr<GHashTable> attributes = adoptGRef(secret_item_get_attributes(secretItem.get())); 237 242 String user = String::fromUTF8(static_cast<const char*>(g_hash_table_lookup(attributes.get(), "user"))); 238 243 if (user.isEmpty()) { 239 completionHandler({ });244 data->completionHandler({ }); 240 245 return; 241 246 } … … 244 249 GRefPtr<SecretValue> secretValue = adoptGRef(secret_item_get_secret(secretItem.get())); 245 250 const char* passwordData = secret_value_get(secretValue.get(), &length); 246 completionHandler(Credential(user, String::fromUTF8(passwordData, length), CredentialPersistencePermanent));247 }, this);251 data->completionHandler(Credential(user, String::fromUTF8(passwordData, length), CredentialPersistencePermanent)); 252 }, data.release()); 248 253 #else 249 254 UNUSED_PARAM(protectionSpace); -
releases/WebKitGTK/webkit-2.20/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
r227455 r230425 836 836 // will become session credentials after the first use. 837 837 if (useCredentialStorage && d->m_context && d->m_context->isValid()) { 838 d->m_context->storageSession().getCredentialFromPersistentStorage(challenge.protectionSpace(), [this, protectedThis = makeRef(*this)] (Credential&& credential) {838 d->m_context->storageSession().getCredentialFromPersistentStorage(challenge.protectionSpace(), d->m_cancellable.get(), [this, protectedThis = makeRef(*this)] (Credential&& credential) { 839 839 continueDidReceiveAuthenticationChallenge(WTFMove(credential)); 840 840 }); -
releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog
r230424 r230425 1 2018-04-03 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] NetworkProcess from WebKitGtk+ 2.19.9x SIGSEVs in NetworkStorageSession (secret search callback) 4 https://bugs.webkit.org/show_bug.cgi?id=183346 5 6 Reviewed by Michael Catanzaro. 7 8 Pass the request cancellable to NetworkStorageSession::getCredentialFromPersistentStorage(). 9 10 * NetworkProcess/soup/NetworkDataTaskSoup.cpp: 11 (WebKit::NetworkDataTaskSoup::authenticate): 12 1 13 2018-04-02 Michael Catanzaro <mcatanzaro@igalia.com> 2 14 -
releases/WebKitGTK/webkit-2.20/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
r228730 r230425 500 500 if (m_storedCredentialsPolicy == StoredCredentialsPolicy::Use) { 501 501 auto protectionSpace = challenge.protectionSpace(); 502 m_session->networkStorageSession().getCredentialFromPersistentStorage(protectionSpace, 502 m_session->networkStorageSession().getCredentialFromPersistentStorage(protectionSpace, m_cancellable.get(), 503 503 [this, protectedThis = makeRef(*this), authChallenge = WTFMove(challenge)] (Credential&& credential) mutable { 504 504 if (m_state == State::Canceling || m_state == State::Completed || !m_client) {
Note: See TracChangeset
for help on using the changeset viewer.