Make ReadArbitraryRange safer to handle

This commit is contained in:
Matt Nadareski
2025-09-03 10:41:53 -04:00
parent 6904674785
commit b1600ad7d2
4 changed files with 48 additions and 13 deletions

View File

@@ -73,9 +73,18 @@ namespace BinaryObjectScanner.Protection
public string? CheckExecutable(string file, NewExecutable nex, bool includeDebug)
{
// TODO: Don't read entire file
var data = nex.ReadArbitraryRange();
if (data == null)
byte[]? data;
try
{
data = nex.ReadArbitraryRange();
if (data == null)
return null;
}
catch
{
// Ignore errors reading ranges
return null;
}
// TODO: Figure out what NE section this lives in
var neMatchSets = new List<ContentMatchSet>

View File

@@ -52,9 +52,18 @@ namespace BinaryObjectScanner.Protection
}
// TODO: Don't read entire file
var data = nex.ReadArbitraryRange();
if (data == null)
byte[]? data;
try
{
data = nex.ReadArbitraryRange();
if (data == null)
return null;
}
catch
{
// Ignore errors reading ranges
return null;
}
var neMatchSets = new List<ContentMatchSet>
{

View File

@@ -41,9 +41,18 @@ namespace BinaryObjectScanner.Protection
public string? CheckExecutable(string file, NewExecutable nex, bool includeDebug)
{
// TODO: Don't read entire file
var data = nex.ReadArbitraryRange();
if (data == null)
byte[]? data;
try
{
data = nex.ReadArbitraryRange();
if (data == null)
return null;
}
catch
{
// Ignore errors reading ranges
return null;
}
// TODO: Figure out what NE section this lives in
var neMatchSets = new List<ContentMatchSet>