Changeset 263622 in webkit


Ignore:
Timestamp:
Jun 27, 2020 9:13:56 AM (4 years ago)
Author:
youenn@apple.com
Message:

Protect SWServer::claim from a registration without active worker
https://bugs.webkit.org/show_bug.cgi?id=213597

Reviewed by Chris Dumez.

SWServerWorker might be active while being terminated.
If terminated as part of SWServerRegistration::clear, the registration no longer has a service worker.
SWServer::claim should therefore check for registration active worker.
This is difficult to test as one needs to claim at the time the service worker is being terminated but not yet terminated.

  • workers/service/server/SWServer.cpp:

(WebCore::SWServer::claim):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r263617 r263622  
     12020-06-27  Youenn Fablet  <youenn@apple.com>
     2
     3        Protect SWServer::claim from a registration without active worker
     4        https://bugs.webkit.org/show_bug.cgi?id=213597
     5
     6        Reviewed by Chris Dumez.
     7
     8        SWServerWorker might be active while being terminated.
     9        If terminated as part of SWServerRegistration::clear, the registration no longer has a service worker.
     10        SWServer::claim should therefore check for registration active worker.
     11        This is difficult to test as one needs to claim at the time the service worker is being terminated but not yet terminated.
     12
     13        * workers/service/server/SWServer.cpp:
     14        (WebCore::SWServer::claim):
     15
    1162020-06-27  Sam Weinig  <weinig@apple.com>
    217
  • trunk/Source/WebCore/workers/service/server/SWServer.cpp

    r263521 r263622  
    582582Optional<ExceptionData> SWServer::claim(SWServerWorker& worker)
    583583{
    584     if (!worker.isActive())
     584    auto* registration = worker.registration();
     585    if (!registration || &worker != registration->activeWorker())
    585586        return ExceptionData { InvalidStateError, "Service worker is not active"_s };
    586587
    587588    auto& origin = worker.origin();
    588589    forEachClientForOrigin(origin, [&](auto& clientData) {
    589         auto* registration = this->doRegistrationMatching(origin.topOrigin, clientData.url);
    590         if (!(registration && registration->key() == worker.registrationKey()))
     590        if (doRegistrationMatching(origin.topOrigin, clientData.url) != registration)
    591591            return;
    592592
Note: See TracChangeset for help on using the changeset viewer.