From 290cb74540e62fde84de1a4674d5e1a41952f0ec Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 20 Jul 2017 13:12:36 +0100 Subject: [PATCH] Do not add drivers of size 0 neither Apple_Free partitions as these can expand beyond the disc on optical media. --- DiscImageChef.Partitions/AppleMap.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DiscImageChef.Partitions/AppleMap.cs b/DiscImageChef.Partitions/AppleMap.cs index d70dd653..6f9b9914 100644 --- a/DiscImageChef.Partitions/AppleMap.cs +++ b/DiscImageChef.Partitions/AppleMap.cs @@ -109,6 +109,9 @@ namespace DiscImageChef.PartPlugins DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddSize = {0}", ddm.sbMap[i].ddSize, i); DicConsole.DebugWriteLine("AppleMap Plugin", "ddm.sbMap[{1}].ddType = {0}", ddm.sbMap[i].ddType, i); + if(ddm.sbMap[i].ddSize == 0) + continue; + CommonTypes.Partition part = new CommonTypes.Partition() { Size = (ulong)(ddm.sbMap[i].ddSize * 512), @@ -119,6 +122,9 @@ namespace DiscImageChef.PartPlugins Type = "Apple_Driver" }; + if((ddm.sbMap[i].ddSize * 512) % sector_size > 0) + part.Length++; + partitions.Add(part); sequence++; @@ -261,7 +267,9 @@ namespace DiscImageChef.PartPlugins // BeOS doesn't mark its partitions as valid //if(flags.HasFlag(AppleMapFlags.Valid) && - if(StringHandlers.CToString(entry.type) != "Apple_partition_map" && entry.sectors > 0) + if(StringHandlers.CToString(entry.type) != "Apple_partition_map" && entry.sectors > 0 && + // Some CD and DVDs end with an Apple_Free that expands beyond the disc size... + StringHandlers.CToString(entry.type) != "Apple_Free") { StringBuilder sb = new StringBuilder();