mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Fix mounting CD-i, High Sierra or ISO9660 with an invalid path table. Fixes #495.
This commit is contained in:
@@ -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)
|
||||
|
||||
24
Aaru.Tests/Issues/495.cs
Normal file
24
Aaru.Tests/Issues/495.cs
Normal file
@@ -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<string, string> ParsedOptions => new Dictionary<string, string>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user