mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-19 07:15:10 +00:00
Stream safety and better streams
This commit is contained in:
@@ -29,8 +29,7 @@ namespace BurnOutSharp.Builder
|
||||
return null;
|
||||
|
||||
// Create a memory stream and parse that
|
||||
MemoryStream dataStream = new MemoryStream(data);
|
||||
dataStream.Position = offset;
|
||||
MemoryStream dataStream = new MemoryStream(data, offset, data.Length - offset);
|
||||
return ParseExecutable(dataStream);
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ namespace BurnOutSharp.Builder
|
||||
public static Executable ParseExecutable(Stream data)
|
||||
{
|
||||
// If the data is invalid
|
||||
if (data == null)
|
||||
if (data == null || data.Length == 0 || !data.CanSeek || !data.CanRead)
|
||||
return null;
|
||||
|
||||
// If the offset is out of bounds
|
||||
|
||||
Reference in New Issue
Block a user