Only read resources that are valid

This commit is contained in:
Matt Nadareski
2024-05-08 12:02:48 -04:00
parent afa239056e
commit 4f374ee885

View File

@@ -1194,7 +1194,7 @@ namespace SabreTools.Serialization.Deserializers
// Read the data from the offset
offset = resourceDataEntry.DataRVA.ConvertVirtualAddress(sections);
if (offset > 0 && resourceDataEntry.Size > 0)
if (offset > 0 && resourceDataEntry.Size > 0 && offset + (int)resourceDataEntry.Size < data.Length)
{
data.Seek(offset, SeekOrigin.Begin);
resourceDataEntry.Data = data.ReadBytes((int)resourceDataEntry.Size);