Changeset 220723 in webkit


Ignore:
Timestamp:
Aug 14, 2017 4:33:27 PM (7 years ago)
Author:
jer.noble@apple.com
Message:

Obj-C exception crash in AVStreamSession when using EME in Private Browsing mode
https://bugs.webkit.org/show_bug.cgi?id=175547

Reviewed by Eric Carlson.

When the storagePath() is empty, do not use those AVStreamSession APIs which require a valid file path to stored
proof-of-key-release data.

Drive-by fix: return emptyString() from HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory() when in Private
Browsing mode, to match the behavior of WebKitMediaKeySession.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory const):

  • platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:

(WebCore::CDMSessionAVStreamSession::releaseKeys):
(WebCore::CDMSessionAVStreamSession::update):
(WebCore::CDMSessionAVStreamSession::generateKeyReleaseMessage):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r220722 r220723  
     12017-08-14  Jer Noble  <jer.noble@apple.com>
     2
     3        Obj-C exception crash in AVStreamSession when using EME in Private Browsing mode
     4        https://bugs.webkit.org/show_bug.cgi?id=175547
     5
     6        Reviewed by Eric Carlson.
     7
     8        When the storagePath() is empty, do not use those AVStreamSession APIs which require a valid file path to stored
     9        proof-of-key-release data.
     10
     11        Drive-by fix: return emptyString() from HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory() when in Private
     12        Browsing mode, to match the behavior of WebKitMediaKeySession.
     13
     14        * html/HTMLMediaElement.cpp:
     15        (WebCore::HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory const):
     16        * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
     17        (WebCore::CDMSessionAVStreamSession::releaseKeys):
     18        (WebCore::CDMSessionAVStreamSession::update):
     19        (WebCore::CDMSessionAVStreamSession::generateKeyReleaseMessage):
     20
    1212017-08-14  Andy Estes  <aestes@apple.com>
    222
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r220472 r220723  
    25172517String HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory() const
    25182518{
     2519    auto* page = document().page();
     2520    if (!page || page->usesEphemeralSession())
     2521        return emptyString();
     2522
    25192523    String storageDirectory = document().settings().mediaKeysStorageDirectory();
    25202524    if (storageDirectory.isEmpty())
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm

    r219767 r220723  
    143143            return;
    144144
    145         if (![getAVStreamSessionClass() respondsToSelector:@selector(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:)])
     145        String storagePath = this->storagePath();
     146        if (storagePath.isEmpty() || ![getAVStreamSessionClass() respondsToSelector:@selector(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:)])
    146147            return;
    147148
    148149        RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
    149         NSArray* expiredSessions = [getAVStreamSessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath()]];
     150        NSArray* expiredSessions = [getAVStreamSessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]];
    150151        for (NSData* expiredSessionData in expiredSessions) {
    151152            NSDictionary *expiredSession = [NSPropertyListSerialization propertyListWithData:expiredSessionData options:kCFPropertyListImmutable format:nullptr error:nullptr];
     
    201202#pragma clang diagnostic push
    202203#pragma clang diagnostic ignored "-Wobjc-literal-conversion"
    203         if ([getAVStreamSessionClass() respondsToSelector:@selector(removePendingExpiredSessionReports:withAppIdentifier:storageDirectoryAtURL:)])
    204             [getAVStreamSessionClass() removePendingExpiredSessionReports:@[m_expiredSession.get()] withAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath()]];
     204        String storagePath = this->storagePath();
     205        if (!storagePath.isEmpty() && [getAVStreamSessionClass() respondsToSelector:@selector(removePendingExpiredSessionReports:withAppIdentifier:storageDirectoryAtURL:)])
     206            [getAVStreamSessionClass() removePendingExpiredSessionReports:@[m_expiredSession.get()] withAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]];
    205207#pragma clang diagnostic pop
    206208        m_expiredSession = nullptr;
     
    317319    RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
    318320
    319     if (![getAVStreamSessionClass() respondsToSelector:@selector(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:)]) {
     321    String storagePath = this->storagePath();
     322    if (storagePath.isEmpty() || ![getAVStreamSessionClass() respondsToSelector:@selector(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:)]) {
    320323        errorCode = MediaPlayer::KeySystemNotSupported;
    321324        systemCode = '!mor';
     
    323326    }
    324327
    325     NSArray* expiredSessions = [getAVStreamSessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath()]];
     328    NSArray* expiredSessions = [getAVStreamSessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]];
    326329    if (![expiredSessions count]) {
    327330        LOG(Media, "CDMSessionAVStreamSession::generateKeyReleaseMessage(%p) - no expired sessions found", this);
Note: See TracChangeset for help on using the changeset viewer.