mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
(ArcOpener.TryOpen): additional count sanity check.
This commit is contained in:
parent
ae900e22ea
commit
9371221b19
@ -81,10 +81,13 @@ namespace GameRes.Formats.Rpm
|
|||||||
set { KnownSchemes = ((ArcScheme)value).KnownSchemes; }
|
set { KnownSchemes = ((ArcScheme)value).KnownSchemes; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Minimum entry length across all possible archive schemes.</summary>
|
||||||
|
const int MinEntryLength = 0x24;
|
||||||
|
|
||||||
public override ArcFile TryOpen (ArcView file)
|
public override ArcFile TryOpen (ArcView file)
|
||||||
{
|
{
|
||||||
int count = file.View.ReadInt32 (0);
|
int count = file.View.ReadInt32 (0);
|
||||||
if (!IsSaneCount (count))
|
if (!IsSaneCount (count) || 8 + count * MinEntryLength >= file.MaxOffset)
|
||||||
return null;
|
return null;
|
||||||
uint is_compressed = file.View.ReadUInt32 (4);
|
uint is_compressed = file.View.ReadUInt32 (4);
|
||||||
if (is_compressed > 1) // should be either 0 or 1
|
if (is_compressed > 1) // should be either 0 or 1
|
||||||
|
Loading…
Reference in New Issue
Block a user