⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267106 in webkit


Ignore:
Timestamp:
Sep 15, 2020, 3:25:16 PM (6 years ago)
Author:
jer.noble@apple.com
Message:

CRASH: Exception thrown from -[AVContentKeyRequest makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:]
https://bugs.webkit.org/show_bug.cgi?id=216580
<rdar://problem/68866834>

Reviewed by Eric Carlson.

Protect against undocumented exceptions thrown from AVContentKeySession (and related) APIs by wrapping in @try/@catch blocks and firing
the correct failure callbacks if an exception is encountered.

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

(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequests):
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRenewingRequest):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267101 r267106  
     12020-09-15  Jer Noble  <jer.noble@apple.com>
     2
     3        CRASH: Exception thrown from -[AVContentKeyRequest makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:]
     4        https://bugs.webkit.org/show_bug.cgi?id=216580
     5        <rdar://problem/68866834>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Protect against undocumented exceptions thrown from AVContentKeySession (and related) APIs by wrapping in @try/@catch blocks and firing
     10        the correct failure callbacks if an exception is encountered.
     11
     12        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
     13        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):
     14        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequests):
     15        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRenewingRequest):
     16
    1172020-09-15  Fujii Hironori  <Hironori.Fujii@sony.com>
    218
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm

    r266885 r267106  
    10671067
    10681068    RetainPtr<NSData> contentIdentifier = keyIDs.first()->createNSData();
    1069     [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable {
    1070         callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] {
    1071             if (!weakThis)
    1072                 return;
    1073 
    1074             if (m_sessionId.isEmpty()) {
    1075                 auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier;
    1076                 sessionIdentifierChanged(sessionID);
    1077             }
    1078 
    1079             if (error && m_requestLicenseCallback)
    1080                 m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed);
    1081             else if (m_requestLicenseCallback)
    1082                 m_requestLicenseCallback(SharedBuffer::create(contentKeyRequestData.get()), m_sessionId, false, Succeeded);
    1083             else if (m_client)
    1084                 m_client->sendMessage(CDMMessageType::LicenseRequest, SharedBuffer::create(contentKeyRequestData.get()));
    1085             ASSERT(!m_requestLicenseCallback);
    1086         });
    1087     }];
     1069    @try {
     1070        [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable {
     1071            callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] {
     1072                if (!weakThis)
     1073                    return;
     1074
     1075                if (m_sessionId.isEmpty()) {
     1076                    auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier;
     1077                    sessionIdentifierChanged(sessionID);
     1078                }
     1079
     1080                if (error && m_requestLicenseCallback)
     1081                    m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed);
     1082                else if (m_requestLicenseCallback)
     1083                    m_requestLicenseCallback(SharedBuffer::create(contentKeyRequestData.get()), m_sessionId, false, Succeeded);
     1084                else if (m_client)
     1085                    m_client->sendMessage(CDMMessageType::LicenseRequest, SharedBuffer::create(contentKeyRequestData.get()));
     1086                ASSERT(!m_requestLicenseCallback);
     1087            });
     1088        }];
     1089    } @catch(NSException *exception) {
     1090        ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]);
     1091        if (m_updateLicenseCallback)
     1092            m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed);
     1093        ASSERT(!m_updateLicenseCallback);
     1094    }
    10881095}
    10891096
     
    11701177    });
    11711178
    1172     for (auto request : m_currentRequest.value().requests) {
    1173         auto keyIDs = keyIDsForRequest(request.get());
    1174         RefPtr<SharedBuffer> keyID = WTFMove(keyIDs.first());
    1175         auto contentIdentifier = keyID->createNSData();
    1176         [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *error) mutable {
    1177             UNUSED_PARAM(error);
    1178             callOnMainThread([keyID = WTFMove(keyID), aggregator = WTFMove(aggregator), contentKeyRequestData = retainPtr(contentKeyRequestData)] () mutable {
    1179                 aggregator->requestsData.append({ WTFMove(keyID), WTFMove(contentKeyRequestData) });
    1180             });
    1181         }];
     1179    @try {
     1180        for (auto request : m_currentRequest.value().requests) {
     1181            auto keyIDs = keyIDsForRequest(request.get());
     1182            RefPtr<SharedBuffer> keyID = WTFMove(keyIDs.first());
     1183            auto contentIdentifier = keyID->createNSData();
     1184            [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *error) mutable {
     1185                UNUSED_PARAM(error);
     1186                callOnMainThread([keyID = WTFMove(keyID), aggregator = WTFMove(aggregator), contentKeyRequestData = retainPtr(contentKeyRequestData)] () mutable {
     1187                    aggregator->requestsData.append({ WTFMove(keyID), WTFMove(contentKeyRequestData) });
     1188                });
     1189            }];
     1190        }
     1191    } @catch(NSException *exception) {
     1192        ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]);
     1193        if (m_requestLicenseCallback)
     1194            m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed);
     1195        ASSERT(!m_requestLicenseCallback);
    11821196    }
    11831197}
     
    12081222
    12091223    RetainPtr<NSData> contentIdentifier = keyIDs.first()->createNSData();
    1210     [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable {
    1211         callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] {
    1212             if (!weakThis || !m_client || error)
    1213                 return;
    1214 
    1215             if (error && m_updateLicenseCallback)
    1216                 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed);
    1217             else if (m_updateLicenseCallback)
    1218                 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, Message(MessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())), Succeeded);
    1219             else if (m_client)
    1220                 m_client->sendMessage(CDMMessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get()));
    1221             ASSERT(!m_updateLicenseCallback);
    1222         });
    1223     }];
     1224    @try {
     1225        [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable {
     1226            callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] {
     1227                if (!weakThis || !m_client || error)
     1228                    return;
     1229
     1230                if (error && m_updateLicenseCallback)
     1231                    m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed);
     1232                else if (m_updateLicenseCallback)
     1233                    m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, Message(MessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())), Succeeded);
     1234                else if (m_client)
     1235                    m_client->sendMessage(CDMMessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get()));
     1236                ASSERT(!m_updateLicenseCallback);
     1237            });
     1238        }];
     1239    } @catch(NSException *exception) {
     1240        ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]);
     1241        if (m_updateLicenseCallback)
     1242            m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed);
     1243        ASSERT(!m_updateLicenseCallback);
     1244    }
    12241245}
    12251246
Note: See TracChangeset for help on using the changeset viewer.