From ebb6c91a738c95ebd57a7f626ac41841d96c8e19 Mon Sep 17 00:00:00 2001 From: morkt Date: Sun, 10 Jul 2016 12:18:38 +0400 Subject: [PATCH] additonal checks to reduce false positives. --- ArcFormats/Eushully/ImageGP.cs | 4 +++- ArcFormats/Macromedia/ImageBITD.cs | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ArcFormats/Eushully/ImageGP.cs b/ArcFormats/Eushully/ImageGP.cs index 6d2f6968..7dc45e16 100644 --- a/ArcFormats/Eushully/ImageGP.cs +++ b/ArcFormats/Eushully/ImageGP.cs @@ -69,7 +69,9 @@ namespace GameRes.Formats.Eushully int palette_size = reader.ReadInt32(); uint width = reader.ReadUInt16(); uint height = reader.ReadUInt16(); - if (0 == palette_size || 0 == width || 0 == height || palette_size >= stream.Length) + if (palette_size <= 0 || 0 == width || 0 == height || palette_size >= stream.Length) + return null; + if (bpp <= 8 && palette_size > 0x100) return null; return new GpMetaData { diff --git a/ArcFormats/Macromedia/ImageBITD.cs b/ArcFormats/Macromedia/ImageBITD.cs index fb7d0fcd..7abfdf59 100644 --- a/ArcFormats/Macromedia/ImageBITD.cs +++ b/ArcFormats/Macromedia/ImageBITD.cs @@ -90,7 +90,13 @@ namespace GameRes.Formats.Selen ++count; if (count > 0x7f) return null; - m_input.Seek (b > 0x7f ? 1 : count, SeekOrigin.Current); + if (b > 0x7f) + { + if (-1 == m_input.ReadByte()) + return null; + } + else + m_input.Seek (count, SeekOrigin.Current); key_lines.Clear(); key_lines.AddRange (scan_lines.Keys); @@ -118,6 +124,7 @@ namespace GameRes.Formats.Selen var valid_lines = from line in scan_lines where line.Key == line.Value orderby line.Key select line.Key; + bool is_eof = -1 == m_input.ReadByte(); foreach (var width in valid_lines) { int height = Math.DivRem (total, width, out rem);