From 1790d82a6e6dad62034f7ffc4340362c1f131ffe Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 17 Dec 2024 15:50:02 -0500 Subject: [PATCH] Cap overlay checks to 16 MiB --- SabreTools.Serialization/Wrappers/PortableExecutable.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SabreTools.Serialization/Wrappers/PortableExecutable.cs b/SabreTools.Serialization/Wrappers/PortableExecutable.cs index cf721cc3..94518249 100644 --- a/SabreTools.Serialization/Wrappers/PortableExecutable.cs +++ b/SabreTools.Serialization/Wrappers/PortableExecutable.cs @@ -376,8 +376,11 @@ namespace SabreTools.Serialization.Wrappers return _overlayStrings; } + // TODO: Revisit the 16 MiB limit + // Cap the check for overlay strings to 16 MiB (arbitrary) + int overlayLength = Math.Min(endOfFile - endOfSectionData, 16 * 1024 * 1024); + // Otherwise, cache and return the strings - int overlayLength = endOfFile - endOfSectionData; _overlayStrings = ReadStringsFromDataSource(endOfSectionData, overlayLength, charLimit: 3); return _overlayStrings; }