Changeset 267425 in webkit
- Timestamp:
- Sep 22, 2020, 11:43:01 AM (6 years ago)
- Location:
- branches/safari-610.2.5.1-branch/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-610.2.5.1-branch/Source/WebCore/ChangeLog
r267423 r267425 1 2020-09-22 Russell Epstein <repstein@apple.com>2 3 Cherry-pick r267106. rdar://problem/693750004 5 CRASH: Exception thrown from -[AVContentKeyRequest makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:]6 https://bugs.webkit.org/show_bug.cgi?id=2165807 <rdar://problem/68866834>8 9 Reviewed by Eric Carlson.10 11 Protect against undocumented exceptions thrown from AVContentKeySession (and related) APIs by wrapping in @try/@catch blocks and firing12 the correct failure callbacks if an exception is encountered.13 14 * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:15 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):16 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequests):17 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRenewingRequest):18 19 20 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267106 268f45cc-cd09-0410-ab3c-d52691b4dbfc21 22 2020-09-15 Jer Noble <jer.noble@apple.com>23 24 CRASH: Exception thrown from -[AVContentKeyRequest makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:]25 https://bugs.webkit.org/show_bug.cgi?id=21658026 <rdar://problem/68866834>27 28 Reviewed by Eric Carlson.29 30 Protect against undocumented exceptions thrown from AVContentKeySession (and related) APIs by wrapping in @try/@catch blocks and firing31 the correct failure callbacks if an exception is encountered.32 33 * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:34 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequest):35 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRequests):36 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::didProvideRenewingRequest):37 38 1 2020-09-11 Alan Coon <alancoon@apple.com> 39 2 -
branches/safari-610.2.5.1-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm
r267420 r267425 1045 1045 1046 1046 RetainPtr<NSData> contentIdentifier = keyIDs.first()->createNSData(); 1047 @try { 1048 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1049 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1050 if (!weakThis) 1051 return; 1052 1053 if (m_sessionId.isEmpty()) { 1054 auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier; 1055 sessionIdentifierChanged(sessionID); 1056 } 1057 1058 if (error && m_requestLicenseCallback) 1059 m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed); 1060 else if (m_requestLicenseCallback) 1061 m_requestLicenseCallback(SharedBuffer::create(contentKeyRequestData.get()), m_sessionId, false, Succeeded); 1062 else if (m_client) 1063 m_client->sendMessage(CDMMessageType::LicenseRequest, SharedBuffer::create(contentKeyRequestData.get())); 1064 ASSERT(!m_requestLicenseCallback); 1065 }); 1066 }]; 1067 } @catch(NSException *exception) { 1068 ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]); 1069 if (m_updateLicenseCallback) 1070 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1071 ASSERT(!m_updateLicenseCallback); 1072 } 1047 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1048 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1049 if (!weakThis) 1050 return; 1051 1052 if (m_sessionId.isEmpty()) { 1053 auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier; 1054 sessionIdentifierChanged(sessionID); 1055 } 1056 1057 if (error && m_requestLicenseCallback) 1058 m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed); 1059 else if (m_requestLicenseCallback) 1060 m_requestLicenseCallback(SharedBuffer::create(contentKeyRequestData.get()), m_sessionId, false, Succeeded); 1061 else if (m_client) 1062 m_client->sendMessage(CDMMessageType::LicenseRequest, SharedBuffer::create(contentKeyRequestData.get())); 1063 ASSERT(!m_requestLicenseCallback); 1064 }); 1065 }]; 1073 1066 } 1074 1067 … … 1155 1148 }); 1156 1149 1157 @try { 1158 for (auto request : m_currentRequest.value().requests) { 1159 auto keyIDs = keyIDsForRequest(request.get()); 1160 RefPtr<SharedBuffer> keyID = WTFMove(keyIDs.first()); 1161 auto contentIdentifier = keyID->createNSData(); 1162 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *error) mutable { 1163 UNUSED_PARAM(error); 1164 callOnMainThread([keyID = WTFMove(keyID), aggregator = WTFMove(aggregator), contentKeyRequestData = retainPtr(contentKeyRequestData)] () mutable { 1165 aggregator->requestsData.append({ WTFMove(keyID), WTFMove(contentKeyRequestData) }); 1166 }); 1167 }]; 1168 } 1169 } @catch(NSException *exception) { 1170 ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]); 1171 if (m_requestLicenseCallback) 1172 m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed); 1173 ASSERT(!m_requestLicenseCallback); 1150 for (auto request : m_currentRequest.value().requests) { 1151 auto keyIDs = keyIDsForRequest(request.get()); 1152 RefPtr<SharedBuffer> keyID = WTFMove(keyIDs.first()); 1153 auto contentIdentifier = keyID->createNSData(); 1154 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *error) mutable { 1155 UNUSED_PARAM(error); 1156 callOnMainThread([keyID = WTFMove(keyID), aggregator = WTFMove(aggregator), contentKeyRequestData = retainPtr(contentKeyRequestData)] () mutable { 1157 aggregator->requestsData.append({ WTFMove(keyID), WTFMove(contentKeyRequestData) }); 1158 }); 1159 }]; 1174 1160 } 1175 1161 } … … 1200 1186 1201 1187 RetainPtr<NSData> contentIdentifier = keyIDs.first()->createNSData(); 1202 @try { 1203 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1204 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1205 if (!weakThis || !m_client || error) 1206 return; 1207 1208 if (error && m_updateLicenseCallback) 1209 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1210 else if (m_updateLicenseCallback) 1211 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, Message(MessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())), Succeeded); 1212 else if (m_client) 1213 m_client->sendMessage(CDMMessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())); 1214 ASSERT(!m_updateLicenseCallback); 1215 }); 1216 }]; 1217 } @catch(NSException *exception) { 1218 ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]); 1219 if (m_updateLicenseCallback) 1220 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1221 ASSERT(!m_updateLicenseCallback); 1222 } 1188 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1189 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1190 if (!weakThis || !m_client || error) 1191 return; 1192 1193 if (error && m_updateLicenseCallback) 1194 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1195 else if (m_updateLicenseCallback) 1196 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, Message(MessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())), Succeeded); 1197 else if (m_client) 1198 m_client->sendMessage(CDMMessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())); 1199 ASSERT(!m_updateLicenseCallback); 1200 }); 1201 }]; 1223 1202 } 1224 1203
Note:
See TracChangeset
for help on using the changeset viewer.