mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 07:34:00 +08:00
(BmpFormat.ReadMetaData): some fault-tolerance.
This commit is contained in:
parent
79f8548d3e
commit
8808b54c88
@ -110,13 +110,18 @@ namespace GameRes
|
||||
{
|
||||
int c1 = stream.ReadByte();
|
||||
int c2 = stream.ReadByte();
|
||||
if (0x42 != c1 || 0x4d != c2)
|
||||
if ('B' != c1 || 'M' != c2)
|
||||
return null;
|
||||
using (var file = new ArcView.Reader (stream))
|
||||
{
|
||||
uint size = file.ReadUInt32();
|
||||
if (size < 14+40)
|
||||
{
|
||||
// some otherwise valid bitmaps have size field set to zero
|
||||
if (size != 0 || !stream.CanSeek)
|
||||
return null;
|
||||
size = (uint)stream.Length;
|
||||
}
|
||||
SkipBytes (file, 8);
|
||||
uint header_size = file.ReadUInt32();
|
||||
if (header_size < 40 || size-14 < header_size)
|
||||
|
Loading…
Reference in New Issue
Block a user