diff --git a/Aaru.Filesystems/ISO9660/Super.cs b/Aaru.Filesystems/ISO9660/Super.cs index 73b695d71..942d7c411 100644 --- a/Aaru.Filesystems/ISO9660/Super.cs +++ b/Aaru.Filesystems/ISO9660/Super.cs @@ -153,8 +153,8 @@ namespace Aaru.Filesystems if(Encoding.GetString(vdMagic) != ISO_MAGIC && Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC && - Encoding.GetString(vdMagic) != CDI_MAGIC - ) // Recognized, it is an ISO9660, now check for rest of data. + Encoding.GetString(vdMagic) != + CDI_MAGIC) // Recognized, it is an ISO9660, now check for rest of data. { if(counter == 0) return Errno.InvalidArgument; @@ -315,6 +315,13 @@ namespace Aaru.Filesystems _pathTable = _highSierra ? DecodeHighSierraPathTable(pathTableData) : DecodePathTable(pathTableData); + if(_pathTable is null) + { + pathTableData = ReadSingleExtent(pathTableData.Length, pathTableLsbLocation); + + _pathTable = _highSierra ? DecodeHighSierraPathTable(pathTableData) : DecodePathTable(pathTableData); + } + // High Sierra and CD-i do not support Joliet or RRIP if((_highSierra || _cdi) && _namespace != Namespace.Normal && @@ -339,8 +346,8 @@ namespace Aaru.Filesystems rootSize = _highSierra ? hsvd.Value.root_directory_record.size : pvd.Value.root_directory_record.size; - if(pathTableData.Length > 1 && - rootLocation != _pathTable[0].Extent) + if(_pathTable?.Length > 1 && + rootLocation != _pathTable[0].Extent) { AaruConsole.DebugWriteLine("ISO9660 plugin", "Path table and PVD do not point to the same location for the root directory!"); @@ -421,7 +428,7 @@ namespace Aaru.Filesystems } // In case the path table is incomplete - if(_usePathTable && pathTableData.Length == 1) + if(_usePathTable && (_pathTable is null || _pathTable?.Length <= 1)) _usePathTable = false; if(_usePathTable && !_cdi) diff --git a/Aaru.Tests/Issues/495.cs b/Aaru.Tests/Issues/495.cs new file mode 100644 index 000000000..2a80cede5 --- /dev/null +++ b/Aaru.Tests/Issues/495.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.IO; + +namespace Aaru.Tests.Issues +{ + /* https://github.com/aaru-dps/Aaru/issues/495 + * + * SilasLaspada commented on Jan 10, 2021 + * + * Trying to extract files from a CDTV image crashes with "Error reading file: Object reference not set to an instance of an object." + */ + + public class _495 : FsExtractIssueTest + { + public override string DataFolder => Path.Combine(Consts.TEST_FILES_ROOT, "Issues", "Fixed", "issue495"); + public override string TestFile => "NetworkCD.aaruf"; + public override Dictionary ParsedOptions => new Dictionary(); + public override bool Debug => false; + public override bool Xattrs => false; + public override string Encoding => null; + public override bool ExpectPartitions => true; + public override string Namespace => null; + } +} \ No newline at end of file