From 89feec7e4d22fe5fa4aaf7a2bb14f1f46d4d3e93 Mon Sep 17 00:00:00 2001 From: morkt Date: Sat, 28 Jan 2017 14:02:44 +0400 Subject: [PATCH] (NFS): entry name sanity check. --- ArcFormats/Nags/ArcNFS.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ArcFormats/Nags/ArcNFS.cs b/ArcFormats/Nags/ArcNFS.cs index 9d928a71..653c9ac0 100644 --- a/ArcFormats/Nags/ArcNFS.cs +++ b/ArcFormats/Nags/ArcNFS.cs @@ -56,8 +56,7 @@ namespace GameRes.Formats.Nags if (first_offset != 0) return null; - var index = new byte[index_size]; - file.View.Read (4, index, 0, index_size); + var index = file.View.ReadBytes (4, index_size); for (int i = 0; i < index.Length; ++i) index[i] ^= key; @@ -67,6 +66,8 @@ namespace GameRes.Formats.Nags for (int i = 0; i < count; ++i) { var name = Binary.GetCString (index, index_offset, 0x18); + if (0 == name.Length) + return null; var entry = FormatCatalog.Instance.Create (name); entry.Offset = base_offset + LittleEndian.ToUInt32 (index, index_offset+0x18); entry.Size = LittleEndian.ToUInt32 (index, index_offset+0x1C);