Title: [254896] trunk/Source/WebCore
Revision
254896
Author
[email protected]
Date
2020-01-21 17:45:27 -0800 (Tue, 21 Jan 2020)

Log Message

[EME] Only emit an array of persistent-usage-records when we discover > 1
https://bugs.webkit.org/show_bug.cgi?id=206205
<rdar://problem/58691769>

Patch by Jer Noble <[email protected]> on 2020-01-21
Reviewed by Eric Carlson.

The persistent-usage-record cache should never have more than one record per sessionId, but
that assumption is not enforced in the file format. To not break clients that aren't
expecting a serialized plist array, only emit an array when more than one matching data item
is found.

* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254895 => 254896)


--- trunk/Source/WebCore/ChangeLog	2020-01-22 01:30:05 UTC (rev 254895)
+++ trunk/Source/WebCore/ChangeLog	2020-01-22 01:45:27 UTC (rev 254896)
@@ -1,3 +1,19 @@
+2020-01-21  Jer Noble  <[email protected]>
+
+        [EME] Only emit an array of persistent-usage-records when we discover > 1
+        https://bugs.webkit.org/show_bug.cgi?id=206205
+        <rdar://problem/58691769>
+
+        Reviewed by Eric Carlson.
+
+        The persistent-usage-record cache should never have more than one record per sessionId, but
+        that assumption is not enforced in the file format. To not break clients that aren't
+        expecting a serialized plist array, only emit an array when more than one matching data item
+        is found.
+
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+        (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::removeSessionData):
+
 2020-01-21  Alex Christensen  <[email protected]>
 
         Add missing NS_NOESCAPE to CFNetwork SPI

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (254895 => 254896)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2020-01-22 01:30:05 UTC (rev 254895)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2020-01-22 01:45:27 UTC (rev 254896)
@@ -32,6 +32,7 @@
 #import "CDMKeySystemConfiguration.h"
 #import "CDMMediaCapability.h"
 #import "InitDataRegistry.h"
+#import "Logging.h"
 #import "NotImplemented.h"
 #import "SharedBuffer.h"
 #import "TextDecoder.h"
@@ -821,8 +822,22 @@
             return;
         }
 
-        RetainPtr<NSData> expiredSessionsData = [NSPropertyListSerialization dataWithPropertyList:expiredSessionsArray.get() format:NSPropertyListBinaryFormat_v1_0 options:kCFPropertyListImmutable error:nullptr];
+        auto expiredSessionsCount = expiredSessionsArray.get().count;
+        if (!expiredSessionsCount) {
+            // It should not be possible to have a persistent-usage-record session that does not generate
+            // a persistent-usage-record message on close. Signal this by failing and assert.
+            ASSERT_NOT_REACHED();
+            callback(WTFMove(changedKeys), WTF::nullopt, Failed);
+            return;
+        }
 
+        id propertyList = expiredSessionsCount == 1 ? [expiredSessionsArray firstObject] : expiredSessionsArray.get();
+
+        RetainPtr<NSData> expiredSessionsData = [NSPropertyListSerialization dataWithPropertyList:propertyList format:NSPropertyListBinaryFormat_v1_0 options:kCFPropertyListImmutable error:nullptr];
+
+        if (expiredSessionsCount > 1)
+            RELEASE_LOG(EME, "Multiple(%lu) expired session reports found with same sessionID(%s)!", expiredSessionsCount, sessionId.utf8().data());
+
         callback(WTFMove(changedKeys), SharedBuffer::create(expiredSessionsData.get()), Succeeded);
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to