From 919ef2220216c6ced70f8b51b46556ae0e72ab70 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 9 Jul 2015 06:53:55 +0400 Subject: [PATCH] additional sanity checks to reduce false positive detections. --- ArcFormats/ArcCherry.cs | 2 ++ ArcFormats/ArcCircus.cs | 2 +- ArcFormats/ArcKAAS.cs | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ArcFormats/ArcCherry.cs b/ArcFormats/ArcCherry.cs index c0742718..6876a00f 100644 --- a/ArcFormats/ArcCherry.cs +++ b/ArcFormats/ArcCherry.cs @@ -66,6 +66,8 @@ namespace GameRes.Formats.Cherry for (int i = 0; i < count; ++i) { string name = file.View.ReadString (index_offset, 0x10); + if (0 == name.Length) + return null; var offset = base_offset + file.View.ReadUInt32 (index_offset+0x10); Entry entry; if (is_grp) diff --git a/ArcFormats/ArcCircus.cs b/ArcFormats/ArcCircus.cs index f4f48164..2fdce70b 100644 --- a/ArcFormats/ArcCircus.cs +++ b/ArcFormats/ArcCircus.cs @@ -48,7 +48,7 @@ namespace GameRes.Formats.Circus public override ArcFile TryOpen (ArcView file) { int count = file.View.ReadInt32 (0); - if (count <= 0 || count > 0xfffff) + if (count <= 1 || count > 0xfffff) return null; var dir = ReadIndex (file, count, 0x30); if (null == dir) diff --git a/ArcFormats/ArcKAAS.cs b/ArcFormats/ArcKAAS.cs index aee5847b..79e0b8b1 100644 --- a/ArcFormats/ArcKAAS.cs +++ b/ArcFormats/ArcKAAS.cs @@ -35,7 +35,7 @@ namespace GameRes.Formats.KAAS public class PdOpener : ArchiveFormat { public override string Tag { get { return "PD/KAAS"; } } - public override string Description { get { return "KAAS engine resource archive"; } } + public override string Description { get { return "KAAS engine PD resource archive"; } } public override uint Signature { get { return 0; } } public override bool IsHierarchic { get { return false; } } public override bool CanCreate { get { return false; } } @@ -100,7 +100,7 @@ namespace GameRes.Formats.KAAS public class PbOpener : ArchiveFormat { public override string Tag { get { return "PB"; } } - public override string Description { get { return "KAAS engine resource archive"; } } + public override string Description { get { return "KAAS engine PB resource archive"; } } public override uint Signature { get { return 0; } } public override bool IsHierarchic { get { return false; } } public override bool CanCreate { get { return false; } } @@ -113,6 +113,7 @@ namespace GameRes.Formats.KAAS var dir = new List (count); int index_offset = 0x10; bool is_voice = Path.GetFileName (file.Name).Equals ("voice.pb", StringComparison.InvariantCultureIgnoreCase); + int data_offset = index_offset + 8 * count; for (int i = 0; i < count; ++i) { uint offset = file.View.ReadUInt32 (index_offset); @@ -122,7 +123,7 @@ namespace GameRes.Formats.KAAS else entry = new Entry { Name = string.Format ("{0:D4}.pb", i), Type = "archive", Offset = offset }; entry.Size = file.View.ReadUInt32 (index_offset + 4); - if (!entry.CheckPlacement (file.MaxOffset)) + if (offset < data_offset || !entry.CheckPlacement (file.MaxOffset)) return null; dir.Add (entry); index_offset += 8;