mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-20 15:55:15 +00:00
Make ReadArbitraryRange safer
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user