Make ReadArbitraryRange safer

This commit is contained in:
Matt Nadareski
2022-03-15 21:30:46 -07:00
parent 6606b388f6
commit e1e7172561
3 changed files with 33 additions and 17 deletions

View File

@@ -164,16 +164,24 @@ namespace BurnOutSharp.ExecutableType.Microsoft.NE
/// <returns></returns>
public byte[] ReadArbitraryRange(int rangeStart = -1, int length = -1)
{
// If we have a source stream, use that
if (this._sourceStream != null)
return ReadArbitraryRangeFromSourceStream(rangeStart, length);
try
{
// If we have a source stream, use that
if (this._sourceStream != null)
return ReadArbitraryRangeFromSourceStream(rangeStart, length);
// If we have a source array, use that
if (this._sourceArray != null)
return ReadArbitraryRangeFromSourceArray(rangeStart, length);
// If we have a source array, use that
if (this._sourceArray != null)
return ReadArbitraryRangeFromSourceArray(rangeStart, length);
// Otherwise, return null
return null;
// Otherwise, return null
return null;
}
catch (Exception ex)
{
// TODO: How to handle this differently?
return null;
}
}
/// <summary>

View File

@@ -554,16 +554,24 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE
/// <returns></returns>
public byte[] ReadArbitraryRange(int rangeStart = -1, int length = -1)
{
// If we have a source stream, use that
if (this._sourceStream != null)
return ReadArbitraryRangeFromSourceStream(rangeStart, length);
try
{
// If we have a source stream, use that
if (this._sourceStream != null)
return ReadArbitraryRangeFromSourceStream(rangeStart, length);
// If we have a source array, use that
if (this._sourceArray != null)
return ReadArbitraryRangeFromSourceArray(rangeStart, length);
// If we have a source array, use that
if (this._sourceArray != null)
return ReadArbitraryRangeFromSourceArray(rangeStart, length);
// Otherwise, return null
return null;
// Otherwise, return null
return null;
}
catch (Exception ex)
{
// TODO: How to handle this differently?
return null;
}
}
/// <summary>

View File

@@ -254,7 +254,7 @@ namespace BurnOutSharp
if (!File.Exists(file))
return null;
// Initialze the protections found
// Initialize the protections found
var protections = new ConcurrentDictionary<string, ConcurrentQueue<string>>();
// Get the extension for certain checks