Changeset 267429 in webkit
- Timestamp:
- Sep 22, 2020, 12:03:28 PM (6 years ago)
- Location:
- branches/safari-610.2.6.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.6.1-branch/Source/WebCore/ChangeLog
r267297 r267429 1 2020-09-22 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r267106. rdar://problem/69375000 4 5 CRASH: Exception thrown from -[AVContentKeyRequest makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler:] 6 https://bugs.webkit.org/show_bug.cgi?id=216580 7 <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 firing 12 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-d52691b4dbfc 21 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=216580 26 <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 firing 31 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 1 38 2020-09-18 Alan Coon <alancoon@apple.com> 2 39 -
branches/safari-610.2.6.1-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm
r266876 r267429 1065 1065 1066 1066 RetainPtr<NSData> contentIdentifier = keyIDs.first()->createNSData(); 1067 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1068 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1069 if (!weakThis) 1070 return; 1071 1072 if (m_sessionId.isEmpty()) { 1073 auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier; 1074 sessionIdentifierChanged(sessionID); 1075 } 1076 1077 if (error && m_requestLicenseCallback) 1078 m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed); 1079 else if (m_requestLicenseCallback) 1080 m_requestLicenseCallback(SharedBuffer::create(contentKeyRequestData.get()), m_sessionId, false, Succeeded); 1081 else if (m_client) 1082 m_client->sendMessage(CDMMessageType::LicenseRequest, SharedBuffer::create(contentKeyRequestData.get())); 1083 ASSERT(!m_requestLicenseCallback); 1084 }); 1085 }]; 1067 @try { 1068 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1069 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1070 if (!weakThis) 1071 return; 1072 1073 if (m_sessionId.isEmpty()) { 1074 auto sessionID = m_group ? m_group.get().contentProtectionSessionIdentifier : m_session.get().contentProtectionSessionIdentifier; 1075 sessionIdentifierChanged(sessionID); 1076 } 1077 1078 if (error && m_requestLicenseCallback) 1079 m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed); 1080 else if (m_requestLicenseCallback) 1081 m_requestLicenseCallback(SharedBuffer::create(contentKeyRequestData.get()), m_sessionId, false, Succeeded); 1082 else if (m_client) 1083 m_client->sendMessage(CDMMessageType::LicenseRequest, SharedBuffer::create(contentKeyRequestData.get())); 1084 ASSERT(!m_requestLicenseCallback); 1085 }); 1086 }]; 1087 } @catch(NSException *exception) { 1088 ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]); 1089 if (m_updateLicenseCallback) 1090 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1091 ASSERT(!m_updateLicenseCallback); 1092 } 1086 1093 } 1087 1094 … … 1168 1175 }); 1169 1176 1170 for (auto request : m_currentRequest.value().requests) { 1171 auto keyIDs = keyIDsForRequest(request.get()); 1172 RefPtr<SharedBuffer> keyID = WTFMove(keyIDs.first()); 1173 auto contentIdentifier = keyID->createNSData(); 1174 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *error) mutable { 1175 UNUSED_PARAM(error); 1176 callOnMainThread([keyID = WTFMove(keyID), aggregator = WTFMove(aggregator), contentKeyRequestData = retainPtr(contentKeyRequestData)] () mutable { 1177 aggregator->requestsData.append({ WTFMove(keyID), WTFMove(contentKeyRequestData) }); 1178 }); 1179 }]; 1177 @try { 1178 for (auto request : m_currentRequest.value().requests) { 1179 auto keyIDs = keyIDsForRequest(request.get()); 1180 RefPtr<SharedBuffer> keyID = WTFMove(keyIDs.first()); 1181 auto contentIdentifier = keyID->createNSData(); 1182 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[keyID = WTFMove(keyID), aggregator] (NSData *contentKeyRequestData, NSError *error) mutable { 1183 UNUSED_PARAM(error); 1184 callOnMainThread([keyID = WTFMove(keyID), aggregator = WTFMove(aggregator), contentKeyRequestData = retainPtr(contentKeyRequestData)] () mutable { 1185 aggregator->requestsData.append({ WTFMove(keyID), WTFMove(contentKeyRequestData) }); 1186 }); 1187 }]; 1188 } 1189 } @catch(NSException *exception) { 1190 ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]); 1191 if (m_requestLicenseCallback) 1192 m_requestLicenseCallback(SharedBuffer::create(), m_sessionId, false, Failed); 1193 ASSERT(!m_requestLicenseCallback); 1180 1194 } 1181 1195 } … … 1206 1220 1207 1221 RetainPtr<NSData> contentIdentifier = keyIDs.first()->createNSData(); 1208 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1209 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1210 if (!weakThis || !m_client || error) 1211 return; 1212 1213 if (error && m_updateLicenseCallback) 1214 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1215 else if (m_updateLicenseCallback) 1216 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, Message(MessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())), Succeeded); 1217 else if (m_client) 1218 m_client->sendMessage(CDMMessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())); 1219 ASSERT(!m_updateLicenseCallback); 1220 }); 1221 }]; 1222 @try { 1223 [request makeStreamingContentKeyRequestDataForApp:appIdentifier.get() contentIdentifier:contentIdentifier.get() options:nil completionHandler:[this, weakThis = makeWeakPtr(*this)] (NSData *contentKeyRequestData, NSError *error) mutable { 1224 callOnMainThread([this, weakThis = WTFMove(weakThis), error = retainPtr(error), contentKeyRequestData = retainPtr(contentKeyRequestData)] { 1225 if (!weakThis || !m_client || error) 1226 return; 1227 1228 if (error && m_updateLicenseCallback) 1229 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1230 else if (m_updateLicenseCallback) 1231 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, Message(MessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())), Succeeded); 1232 else if (m_client) 1233 m_client->sendMessage(CDMMessageType::LicenseRenewal, SharedBuffer::create(contentKeyRequestData.get())); 1234 ASSERT(!m_updateLicenseCallback); 1235 }); 1236 }]; 1237 } @catch(NSException *exception) { 1238 ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "exception thrown from -makeStreamingContentKeyRequestDataForApp:contentIdentifier:options:completionHandler: ", [[exception name] UTF8String], ", reason : ", [[exception reason] UTF8String]); 1239 if (m_updateLicenseCallback) 1240 m_updateLicenseCallback(false, WTF::nullopt, WTF::nullopt, WTF::nullopt, Failed); 1241 ASSERT(!m_updateLicenseCallback); 1242 } 1222 1243 } 1223 1244
Note:
See TracChangeset
for help on using the changeset viewer.