From b4a94cf2477b2fd616f23479b7a9cc287f7cffd5 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 3 Sep 2025 08:58:48 -0400 Subject: [PATCH] Limit strings to 16KiB --- BinaryObjectScanner/FileType/Executable.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/BinaryObjectScanner/FileType/Executable.cs b/BinaryObjectScanner/FileType/Executable.cs index 327483bc..3275d764 100644 --- a/BinaryObjectScanner/FileType/Executable.cs +++ b/BinaryObjectScanner/FileType/Executable.cs @@ -312,7 +312,7 @@ namespace BinaryObjectScanner.FileType } // Otherwise, cache and return the strings - _overlayStrings[pex] = ReadStringsFrom(overlayData, charLimit: 3) ?? []; + _overlayStrings[pex] = ReadStringsFrom(overlayData, charLimit: 4) ?? []; return _overlayStrings[pex]; } } @@ -328,8 +328,16 @@ namespace BinaryObjectScanner.FileType if (input == null || input.Length == 0) return null; + // Limit to 16KiB of data + if (input.Length > 16384) + { + int offset = 0; + byte[] temp = input.ReadBytes(ref offset, 16384); + input = temp; + } + // Check for ASCII strings - var asciiStrings = ReadStringsWithEncoding(input, charLimit, Encoding.ASCII); + var asciiStrings = ReadStringsWithEncoding(input, charLimit, Encoding.ASCII); // Check for UTF-8 strings // We are limiting the check for Unicode characters with a second byte of 0x00 for now