mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-08 01:30:18 +08:00
additional sanity checks.
This commit is contained in:
@@ -107,6 +107,8 @@ namespace GameRes.Formats.KAAS
|
|||||||
|
|
||||||
public override ArcFile TryOpen (ArcView file)
|
public override ArcFile TryOpen (ArcView file)
|
||||||
{
|
{
|
||||||
|
if (!file.Name.EndsWith (".pb", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
return null;
|
||||||
int count = file.View.ReadInt32 (0);
|
int count = file.View.ReadInt32 (0);
|
||||||
if (count <= 0 || count > 0xfff)
|
if (count <= 0 || count > 0xfff)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace GameRes.Formats.Propeller
|
|||||||
{
|
{
|
||||||
uint index_offset = file.View.ReadUInt32 (0);
|
uint index_offset = file.View.ReadUInt32 (0);
|
||||||
int count = file.View.ReadInt32 (4);
|
int count = file.View.ReadInt32 (4);
|
||||||
if (index_offset >= file.MaxOffset || !IsSaneCount (count))
|
if (index_offset < 8 || index_offset >= file.MaxOffset || !IsSaneCount (count))
|
||||||
return null;
|
return null;
|
||||||
uint index_size = (uint)count * 0x28u;
|
uint index_size = (uint)count * 0x28u;
|
||||||
if (index_size > file.MaxOffset - index_offset)
|
if (index_size > file.MaxOffset - index_offset)
|
||||||
|
|||||||
@@ -208,7 +208,8 @@ namespace GameRes.Formats.Zyx
|
|||||||
Width = file.View.ReadInt32 (index_offset+0x14),
|
Width = file.View.ReadInt32 (index_offset+0x14),
|
||||||
Height = file.View.ReadInt32 (index_offset+0x18),
|
Height = file.View.ReadInt32 (index_offset+0x18),
|
||||||
};
|
};
|
||||||
if (!entry.CheckPlacement (file.MaxOffset))
|
if (entry.Size < 4 || entry.Width <= 0 || entry.Height <= 0
|
||||||
|
|| !entry.CheckPlacement (file.MaxOffset))
|
||||||
return null;
|
return null;
|
||||||
dir.Add (entry);
|
dir.Add (entry);
|
||||||
index_offset += 0x1C;
|
index_offset += 0x1C;
|
||||||
|
|||||||
Reference in New Issue
Block a user