mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Fix plugins crashing when sector is too small.
This commit is contained in:
@@ -197,6 +197,8 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] bootSector = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead);
|
||||
int bootChk = 0;
|
||||
if(bootSector.Length < 512) return false;
|
||||
|
||||
for(int i = 0; i < 0x1FF; i++) bootChk = (bootChk & 0xFF) + (bootChk >> 8) + bootSector[i];
|
||||
|
||||
DicConsole.DebugWriteLine("ADFS Plugin", "bootChk = {0}", bootChk);
|
||||
|
||||
@@ -69,6 +69,9 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] tmp = imagePlugin.ReadSectors(sector + partition.Start, run);
|
||||
byte[] sbSector = new byte[AFS_SUPERBLOCK_SIZE];
|
||||
|
||||
if(offset + AFS_SUPERBLOCK_SIZE > tmp.Length) return false;
|
||||
|
||||
Array.Copy(tmp, offset, sbSector, 0, AFS_SUPERBLOCK_SIZE);
|
||||
|
||||
uint magic = BitConverter.ToUInt32(sbSector, 0x20);
|
||||
|
||||
@@ -104,6 +104,8 @@ namespace DiscImageChef.Filesystems
|
||||
262144 / imagePlugin.Info.SectorSize
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
return locations.Where(loc => partition.End > partition.Start + loc + sbSizeInSectors)
|
||||
.Select(loc => imagePlugin.ReadSectors(partition.Start + loc, sbSizeInSectors))
|
||||
.Select(ufsSbSectors => BitConverter.ToUInt32(ufsSbSectors, 0x055C))
|
||||
@@ -111,6 +113,8 @@ namespace DiscImageChef.Filesystems
|
||||
magic == UFS_CIGAM_BW || magic == UFS2_MAGIC || magic == UFS2_CIGAM ||
|
||||
magic == UFS_BAD_MAGIC || magic == UFS_BAD_CIGAM);
|
||||
}
|
||||
catch(Exception) { return false; }
|
||||
}
|
||||
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
||||
Encoding encoding)
|
||||
|
||||
@@ -56,11 +56,11 @@ namespace DiscImageChef.Filesystems
|
||||
{
|
||||
if(1 + partition.Start >= partition.End) return false;
|
||||
|
||||
if(imagePlugin.Info.SectorSize < 512) return false;
|
||||
|
||||
byte[] magicB = new byte[12];
|
||||
byte[] hbSector = imagePlugin.ReadSector(1 + partition.Start);
|
||||
|
||||
if(hbSector.Length < 512) return false;
|
||||
|
||||
Array.Copy(hbSector, 0x1F0, magicB, 0, 12);
|
||||
string magic = Encoding.ASCII.GetString(magicB);
|
||||
|
||||
|
||||
@@ -181,6 +181,8 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] sbSector = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSizeInSectors);
|
||||
byte[] sb = new byte[sbSizeInBytes];
|
||||
if(sbOff + sbSizeInBytes > sbSector.Length) return false;
|
||||
|
||||
Array.Copy(sbSector, sbOff, sb, 0, sbSizeInBytes);
|
||||
|
||||
ushort magic = BitConverter.ToUInt16(sb, 0x038);
|
||||
|
||||
@@ -66,6 +66,8 @@ namespace DiscImageChef.Filesystems
|
||||
|
||||
byte[] sbSector = imagePlugin.ReadSector(sbSectorOff + partition.Start);
|
||||
byte[] sb = new byte[512];
|
||||
if(sbOff + 512 > sbSector.Length) return false;
|
||||
|
||||
Array.Copy(sbSector, sbOff, sb, 0, 512);
|
||||
|
||||
ushort magic = BitConverter.ToUInt16(sb, 0x038);
|
||||
|
||||
@@ -63,12 +63,12 @@ namespace DiscImageChef.Partitions
|
||||
{
|
||||
partitions = new List<Partition>();
|
||||
|
||||
if(imagePlugin.Info.SectorSize < 512) return false;
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
byte[] sector = imagePlugin.ReadSector(sectorOffset);
|
||||
|
||||
if(sector.Length < 512) return false;
|
||||
|
||||
AtariTable table = new AtariTable
|
||||
{
|
||||
boot = new byte[342],
|
||||
|
||||
Reference in New Issue
Block a user