(BgiAudio.TryOpen): check stream position against file length.

This commit is contained in:
morkt 2015-08-30 03:43:12 +04:00
parent 46bd0a5e47
commit 4bfdc502e4
2 changed files with 5 additions and 4 deletions

View File

@ -49,9 +49,10 @@ namespace GameRes.Formats.BGI
if (!Binary.AsciiEqual (header, 4, "bw ")) if (!Binary.AsciiEqual (header, 4, "bw "))
return null; return null;
uint offset = LittleEndian.ToUInt32 (header, 0); uint offset = LittleEndian.ToUInt32 (header, 0);
file.Seek (offset, SeekOrigin.Begin); if (offset >= file.Length)
return null;
var input = new StreamRegion (file, file.Position); var input = new StreamRegion (file, offset);
return new OggInput (input); return new OggInput (input);
// input is left undisposed in case of exception. // input is left undisposed in case of exception.
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.1.9.417")] [assembly: AssemblyVersion ("1.1.9.418")]
[assembly: AssemblyFileVersion ("1.1.9.417")] [assembly: AssemblyFileVersion ("1.1.9.418")]