mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Don't try to read past partition end.
This commit is contained in:
@@ -391,6 +391,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
if(bootBlockSize % imagePlugin.ImageInfo.sectorSize > 0)
|
if(bootBlockSize % imagePlugin.ImageInfo.sectorSize > 0)
|
||||||
sectorsToRead++;
|
sectorsToRead++;
|
||||||
|
|
||||||
|
if(sbSector + partition.Start + sectorsToRead >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] bootSector = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead);
|
byte[] bootSector = imagePlugin.ReadSectors(sbSector + partition.Start, sectorsToRead);
|
||||||
int bootChk = 0;
|
int bootChk = 0;
|
||||||
for(int i = 0; i < 0x1FF; i++)
|
for(int i = 0; i < 0x1FF; i++)
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
ulong sbSectorOff = 0x10000 / imagePlugin.GetSectorSize();
|
ulong sbSectorOff = 0x10000 / imagePlugin.GetSectorSize();
|
||||||
uint sbSectorSize = 0x1000 / imagePlugin.GetSectorSize();
|
uint sbSectorSize = 0x1000 / imagePlugin.GetSectorSize();
|
||||||
|
|
||||||
if((sbSectorOff + sbSectorSize) >= partition.End)
|
if((sbSectorOff + partition.Start) >= partition.End)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
byte[] sector = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize);
|
byte[] sector = imagePlugin.ReadSectors(sbSectorOff + partition.Start, sbSectorSize);
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
if(Marshal.SizeOf(f2fsSb) % imagePlugin.GetSectorSize() != 0)
|
if(Marshal.SizeOf(f2fsSb) % imagePlugin.GetSectorSize() != 0)
|
||||||
sbSize++;
|
sbSize++;
|
||||||
|
|
||||||
|
if(partition.Start + sbAddr >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
||||||
if(sector.Length < Marshal.SizeOf(f2fsSb))
|
if(sector.Length < Marshal.SizeOf(f2fsSb))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -143,14 +143,17 @@ namespace DiscImageChef.Filesystems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// HPFS
|
// HPFS
|
||||||
uint hpfs_magic1, hpfs_magic2;
|
if(16 + partition.Start <= partition.End)
|
||||||
|
{
|
||||||
|
uint hpfs_magic1, hpfs_magic2;
|
||||||
|
|
||||||
byte[] hpfs_sb_sector = imagePlugin.ReadSector(16 + partition.Start); // Seek to superblock, on logical sector 16
|
byte[] hpfs_sb_sector = imagePlugin.ReadSector(16 + partition.Start); // Seek to superblock, on logical sector 16
|
||||||
hpfs_magic1 = BitConverter.ToUInt32(hpfs_sb_sector, 0x000);
|
hpfs_magic1 = BitConverter.ToUInt32(hpfs_sb_sector, 0x000);
|
||||||
hpfs_magic2 = BitConverter.ToUInt32(hpfs_sb_sector, 0x004);
|
hpfs_magic2 = BitConverter.ToUInt32(hpfs_sb_sector, 0x004);
|
||||||
|
|
||||||
if(hpfs_magic1 == 0xF995E849 && hpfs_magic2 == 0xFA53E9C5)
|
if(hpfs_magic1 == 0xF995E849 && hpfs_magic2 == 0xFA53E9C5)
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// FAT32 for sure
|
// FAT32 for sure
|
||||||
if(bits_in_bps == 1 && correct_spc && fats_no <= 2 && sectors == 0 && fat_sectors == 0 && fat32_signature == 0x29 && fat32_string == "FAT32 ")
|
if(bits_in_bps == 1 && correct_spc && fats_no <= 2 && sectors == 0 && fat_sectors == 0 && fat32_signature == 0x29 && fat32_string == "FAT32 ")
|
||||||
@@ -840,7 +843,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
StringBuilder atariSb = new StringBuilder();
|
StringBuilder atariSb = new StringBuilder();
|
||||||
atariSb.AppendFormat("cmdload will be loaded with value {0:X4}h", BigEndianBitConverter.ToUInt16(bpb_sector, 0x01E)).AppendLine();
|
atariSb.AppendFormat("cmdload will be loaded with value {0:X4}h", BigEndianBitConverter.ToUInt16(bpb_sector, 0x01E)).AppendLine();
|
||||||
atariSb.AppendFormat("Boot program will be loaded at address {0:X4}h", atariBPB.ldaaddr).AppendLine();
|
atariSb.AppendFormat("Boot program will be loaded at address {0:X4}h", atariBPB.ldaaddr).AppendLine();
|
||||||
atariSb.AppendFormat("FAT and directory will be cahed at address {0:X4}h", atariBPB.fatbuf).AppendLine();
|
atariSb.AppendFormat("FAT and directory will be cached at address {0:X4}h", atariBPB.fatbuf).AppendLine();
|
||||||
if(atariBPB.ldmode == 0)
|
if(atariBPB.ldmode == 0)
|
||||||
{
|
{
|
||||||
byte[] tmp = new byte[8];
|
byte[] tmp = new byte[8];
|
||||||
@@ -1130,8 +1133,12 @@ namespace DiscImageChef.Filesystems
|
|||||||
public ushort sectcnt;
|
public ushort sectcnt;
|
||||||
/// <summary>Address where boot code should be loaded.</summary>
|
/// <summary>Address where boot code should be loaded.</summary>
|
||||||
public ushort ldaaddr;
|
public ushort ldaaddr;
|
||||||
|
/// <summary>Padding.</summary>
|
||||||
|
public ushort padding;
|
||||||
/// <summary>Address where FAT and root directory sectors must be loaded.</summary>
|
/// <summary>Address where FAT and root directory sectors must be loaded.</summary>
|
||||||
public ushort fatbuf;
|
public ushort fatbuf;
|
||||||
|
/// <summary>Unknown.</summary>
|
||||||
|
public ushort unknown;
|
||||||
/// <summary>Filename to be loaded for booting.</summary>
|
/// <summary>Filename to be loaded for booting.</summary>
|
||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)]
|
||||||
public byte[] fname;
|
public byte[] fname;
|
||||||
|
|||||||
@@ -59,10 +59,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
|
|
||||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
||||||
{
|
{
|
||||||
if((2 + partition.Start) >= partition.End)
|
if((16 + partition.Start) >= partition.End)
|
||||||
return false;
|
|
||||||
|
|
||||||
if(imagePlugin.ImageInfo.sectors <= 16)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
uint magic1, magic2;
|
uint magic1, magic2;
|
||||||
|
|||||||
@@ -152,6 +152,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
||||||
{
|
{
|
||||||
uint bootSectors = JFS_BootBlocksSize / imagePlugin.GetSectorSize();
|
uint bootSectors = JFS_BootBlocksSize / imagePlugin.GetSectorSize();
|
||||||
|
if(partition.Start + bootSectors >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] sector = imagePlugin.ReadSector(partition.Start + bootSectors);
|
byte[] sector = imagePlugin.ReadSector(partition.Start + bootSectors);
|
||||||
if(sector.Length < 512)
|
if(sector.Length < 512)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -127,6 +127,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
if(Marshal.SizeOf(nilfsSb) % imagePlugin.GetSectorSize() != 0)
|
if(Marshal.SizeOf(nilfsSb) % imagePlugin.GetSectorSize() != 0)
|
||||||
sbSize++;
|
sbSize++;
|
||||||
|
|
||||||
|
if(partition.Start + sbAddr + sbSize >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
||||||
if(sector.Length < Marshal.SizeOf(nilfsSb))
|
if(sector.Length < Marshal.SizeOf(nilfsSb))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
|
|
||||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
||||||
{
|
{
|
||||||
if(partition.Start >= partition.End)
|
if(partition.Length < 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace DiscImageChef.Filesystems
|
|||||||
|
|
||||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
||||||
{
|
{
|
||||||
if(partition.End < 3)
|
if(partition.Length < 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Blocks 0 and 1 are boot code
|
// Blocks 0 and 1 are boot code
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
uint sectors = QNX6_SuperBlockSize / imagePlugin.GetSectorSize();
|
uint sectors = QNX6_SuperBlockSize / imagePlugin.GetSectorSize();
|
||||||
uint bootSectors = QNX6_BootBlocksSize / imagePlugin.GetSectorSize();
|
uint bootSectors = QNX6_BootBlocksSize / imagePlugin.GetSectorSize();
|
||||||
|
|
||||||
|
if(partition.Start + bootSectors + sectors >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] audiSector = imagePlugin.ReadSectors(partition.Start, sectors);
|
byte[] audiSector = imagePlugin.ReadSectors(partition.Start, sectors);
|
||||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors);
|
byte[] sector = imagePlugin.ReadSectors(partition.Start + bootSectors, sectors);
|
||||||
if(sector.Length < QNX6_SuperBlockSize)
|
if(sector.Length < QNX6_SuperBlockSize)
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
if(Marshal.SizeOf(reiserSb) % imagePlugin.GetSectorSize() != 0)
|
if(Marshal.SizeOf(reiserSb) % imagePlugin.GetSectorSize() != 0)
|
||||||
sbSize++;
|
sbSize++;
|
||||||
|
|
||||||
|
if(partition.Start + sbAddr + sbSize >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
||||||
if(sector.Length < Marshal.SizeOf(reiserSb))
|
if(sector.Length < Marshal.SizeOf(reiserSb))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ namespace DiscImageChef.Filesystems
|
|||||||
if(Marshal.SizeOf(reiserSb) % imagePlugin.GetSectorSize() != 0)
|
if(Marshal.SizeOf(reiserSb) % imagePlugin.GetSectorSize() != 0)
|
||||||
sbSize++;
|
sbSize++;
|
||||||
|
|
||||||
|
if(partition.Start + sbAddr + sbSize >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
byte[] sector = imagePlugin.ReadSectors(partition.Start + sbAddr, sbSize);
|
||||||
if(sector.Length < Marshal.SizeOf(reiserSb))
|
if(sector.Length < Marshal.SizeOf(reiserSb))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace DiscImageChef.Filesystems.UCSDPascal
|
|||||||
{
|
{
|
||||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
||||||
{
|
{
|
||||||
if(imagePlugin.GetSectors() < 3)
|
if(partition.Length < 3)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Blocks 0 and 1 are boot code
|
// Blocks 0 and 1 are boot code
|
||||||
|
|||||||
@@ -210,10 +210,11 @@ namespace DiscImageChef.Filesystems
|
|||||||
|
|
||||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
||||||
{
|
{
|
||||||
if(partition.Start >= partition.End)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ulong vmfsSuperOff = VxFS_Base / imagePlugin.ImageInfo.sectorSize;
|
ulong vmfsSuperOff = VxFS_Base / imagePlugin.ImageInfo.sectorSize;
|
||||||
|
|
||||||
|
if(partition.Start + vmfsSuperOff >= partition.End)
|
||||||
|
return false;
|
||||||
|
|
||||||
byte[] sector = imagePlugin.ReadSector(partition.Start + vmfsSuperOff);
|
byte[] sector = imagePlugin.ReadSector(partition.Start + vmfsSuperOff);
|
||||||
|
|
||||||
uint magic = BitConverter.ToUInt32(sector, 0x00);
|
uint magic = BitConverter.ToUInt32(sector, 0x00);
|
||||||
|
|||||||
Reference in New Issue
Block a user