From 9371221b19932ce6aa93fbba33ac291d8235c94e Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 20 Sep 2015 05:40:37 +0400 Subject: [PATCH] (ArcOpener.TryOpen): additional count sanity check. --- ArcFormats/RPM/ArcARC.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ArcFormats/RPM/ArcARC.cs b/ArcFormats/RPM/ArcARC.cs index f5a9f12f..b6ad1553 100644 --- a/ArcFormats/RPM/ArcARC.cs +++ b/ArcFormats/RPM/ArcARC.cs @@ -81,10 +81,13 @@ namespace GameRes.Formats.Rpm set { KnownSchemes = ((ArcScheme)value).KnownSchemes; } } + /// Minimum entry length across all possible archive schemes. + 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