From f5d0f065c131a467bfcf393fd3a553946b57518c Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 16 Sep 2025 20:11:41 -0400 Subject: [PATCH] Handle unknown AACS records a bit better for now --- .../Deserializers/AACS.cs | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/SabreTools.Serialization/Deserializers/AACS.cs b/SabreTools.Serialization/Deserializers/AACS.cs index 60f0080e..398d8241 100644 --- a/SabreTools.Serialization/Deserializers/AACS.cs +++ b/SabreTools.Serialization/Deserializers/AACS.cs @@ -28,7 +28,7 @@ namespace SabreTools.Serialization.Deserializers // Try to parse the record var record = ParseRecord(data); if (record == null) - return null; + continue; // Add the record records.Add(record); @@ -64,27 +64,32 @@ namespace SabreTools.Serialization.Deserializers /// Filled Record on success, null on error private static Record? ParseRecord(Stream data) { - // The first byte is the type + // The first 4 bytes are the type and length RecordType type = (RecordType)data.ReadByteValue(); - data.Seek(-1, SeekOrigin.Current); + uint recordLength = data.ReadUInt24LittleEndian(); + data.Seek(-4, SeekOrigin.Current); // Create a record based on the type - return type switch + switch (type) { // Known record types - RecordType.EndOfMediaKeyBlock => ParseEndOfMediaKeyBlockRecord(data), - RecordType.ExplicitSubsetDifference => ParseExplicitSubsetDifferenceRecord(data), - RecordType.MediaKeyData => ParseMediaKeyDataRecord(data), - RecordType.SubsetDifferenceIndex => ParseSubsetDifferenceIndexRecord(data), - RecordType.TypeAndVersion => ParseTypeAndVersionRecord(data), - RecordType.DriveRevocationList => ParseDriveRevocationListRecord(data), - RecordType.HostRevocationList => ParseHostRevocationListRecord(data), - RecordType.VerifyMediaKey => ParseVerifyMediaKeyRecord(data), - RecordType.Copyright => ParseCopyrightRecord(data), + case RecordType.EndOfMediaKeyBlock: return ParseEndOfMediaKeyBlockRecord(data); + case RecordType.ExplicitSubsetDifference: return ParseExplicitSubsetDifferenceRecord(data); + case RecordType.MediaKeyData: return ParseMediaKeyDataRecord(data); + case RecordType.SubsetDifferenceIndex: return ParseSubsetDifferenceIndexRecord(data); + case RecordType.TypeAndVersion: return ParseTypeAndVersionRecord(data); + case RecordType.DriveRevocationList: return ParseDriveRevocationListRecord(data); + case RecordType.HostRevocationList: return ParseHostRevocationListRecord(data); + case RecordType.VerifyMediaKey: return ParseVerifyMediaKeyRecord(data); + case RecordType.Copyright: return ParseCopyrightRecord(data); // Unknown record type - _ => null, - }; + default: + if (recordLength > 4) + _ = data.ReadBytes((int)recordLength - 4); + return null; + } + ; } ///