(ArcOpener.TryOpen): additional count sanity check.

This commit is contained in:
morkt 2015-09-20 05:40:37 +04:00
parent ae900e22ea
commit 9371221b19

View File

@ -81,10 +81,13 @@ namespace GameRes.Formats.Rpm
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)
{
int count = file.View.ReadInt32 (0);
if (!IsSaneCount (count))
if (!IsSaneCount (count) || 8 + count * MinEntryLength >= file.MaxOffset)
return null;
uint is_compressed = file.View.ReadUInt32 (4);
if (is_compressed > 1) // should be either 0 or 1