Skip to content

Commit ec99304

Browse files
committed
Implement the 16KiB limit
1 parent aefc931 commit ec99304

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

SabreTools.IO/Extensions/ByteArrayExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ public static bool IsNullOrEmpty(this Array? array)
5959
/// </summary>
6060
/// <param name="charLimit">Number of characters needed to be a valid string, default 5</param>
6161
/// <returns>String list containing the requested data, null on error</returns>
62+
/// <remarks>A maximum of 16KiB of data can be scanned at a time</remarks>
6263
public static List<string>? ReadStringsFrom(this byte[]? input, int charLimit = 5)
6364
{
6465
// Validate the data
6566
if (input == null || input.Length == 0)
6667
return null;
6768

69+
// Limit to 16KiB of data
70+
if (input.Length > 16384)
71+
{
72+
int offset = 0;
73+
input = input.ReadBytes(ref offset, 16384);
74+
}
75+
6876
// Check for ASCII strings
6977
var asciiStrings = input.ReadStringsWithEncoding(charLimit, Encoding.ASCII);
7078

0 commit comments

Comments
 (0)