mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
(PmpFormat.ReadMetaData): refined checking for valid zlib stream.
This commit is contained in:
parent
6e0a1ceff5
commit
7b1d5dc2f9
@ -47,9 +47,14 @@ namespace GameRes.Formats.ScenePlayer
|
||||
|
||||
public override ImageMetaData ReadMetaData (Stream stream)
|
||||
{
|
||||
int first = stream.ReadByte();
|
||||
if ((first ^ 0x21) != 0x78) // doesn't look like zlib stream
|
||||
int first = stream.ReadByte() ^ 0x21;
|
||||
if (first != 0x78) // doesn't look like zlib stream
|
||||
return null;
|
||||
int flg = stream.ReadByte() ^ 0x21;
|
||||
int fcheck = first << 8 | flg;
|
||||
if (fcheck / 0x1f * 0x1f != fcheck)
|
||||
return null;
|
||||
|
||||
stream.Position = 0;
|
||||
using (var input = new XoredStream (stream, 0x21, true))
|
||||
using (var zstream = new ZLibStream (input, CompressionMode.Decompress))
|
||||
|
Loading…
x
Reference in New Issue
Block a user