From 32b256b01387f2c88c616073a1b586bb2b0bcbbf Mon Sep 17 00:00:00 2001 From: morkt Date: Sat, 2 Dec 2017 05:10:41 +0400 Subject: [PATCH] (DAT/YaneSDK): added sanity checks. --- ArcFormats/YaneSDK/ArcDAT.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ArcFormats/YaneSDK/ArcDAT.cs b/ArcFormats/YaneSDK/ArcDAT.cs index 4140dabe..304877bb 100644 --- a/ArcFormats/YaneSDK/ArcDAT.cs +++ b/ArcFormats/YaneSDK/ArcDAT.cs @@ -56,6 +56,7 @@ namespace GameRes.Formats.YaneSDK using (var index = new BinaryReader (dec)) { index.BaseStream.Position = 2; + int data_offset = 2 + 0x2C * count; var name_buf = new byte[0x22]; var dir = new List (count); for (int i = 0; i < count; ++i) @@ -63,11 +64,13 @@ namespace GameRes.Formats.YaneSDK if (0x22 != index.Read (name_buf, 0, 0x22)) return null; var name = Binary.GetCString (name_buf, 0); + if (string.IsNullOrWhiteSpace (name)) + return null; var entry = FormatCatalog.Instance.Create (name); entry.EncryptedSize = index.ReadUInt16(); entry.Size = index.ReadUInt32(); entry.Offset = index.ReadUInt32(); - if (!entry.CheckPlacement (file.MaxOffset)) + if (!entry.CheckPlacement (file.MaxOffset) || entry.Offset <= data_offset) return null; dir.Add (entry); }