Fix mounting CD-i, High Sierra or ISO9660 with an invalid path table. Fixes #495.

This commit is contained in:
2021-06-02 21:40:21 +01:00
parent 4ac273175a
commit 31d7daa33b
2 changed files with 36 additions and 5 deletions

View File

@@ -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
View 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;
}
}