Be slightly safer on PE string table parsing

This commit is contained in:
Matt Nadareski
2022-11-09 21:31:40 -08:00
parent 8aa574a7c4
commit 0a0ca9ba93

View File

@@ -541,6 +541,12 @@ namespace BurnOutSharp.Builder
else
{
string fullEncodedString = stringEncoding.GetString(entry.Data, offset, entry.Data.Length - offset);
if (stringLength > fullEncodedString.Length)
{
// TODO: Print to console or return an error?
stringLength = (ushort)fullEncodedString.Length;
}
string stringValue = fullEncodedString.Substring(0, stringLength);
offset += stringEncoding.GetByteCount(stringValue);
stringValue = stringValue.Replace("\n", "\\n").Replace("\r", "\\r");