mirror of
https://github.com/crskycode/GARbro.git
synced 2025-01-11 04:29:15 +08:00
(PngFormat.ReadMetaData): additional sanity checks.
This commit is contained in:
parent
3ad1c60dde
commit
ad16b754ae
@ -129,6 +129,8 @@ namespace GameRes
|
||||
meta.Width = Binary.BigEndian (file.ReadUInt32());
|
||||
meta.Height = Binary.BigEndian (file.ReadUInt32());
|
||||
int bpp = file.ReadByte();
|
||||
if (bpp != 1 && bpp != 2 && bpp != 4 && bpp != 8 && bpp != 16)
|
||||
return null;
|
||||
int color_type = file.ReadByte();
|
||||
switch (color_type)
|
||||
{
|
||||
@ -136,7 +138,8 @@ namespace GameRes
|
||||
case 3: meta.BPP = 24; break;
|
||||
case 4: meta.BPP = bpp*2; break;
|
||||
case 6: meta.BPP = bpp*4; break;
|
||||
default: meta.BPP = bpp; break;
|
||||
case 0: meta.BPP = bpp; break;
|
||||
default: return null;
|
||||
}
|
||||
SkipBytes (file, 7);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user