(DatOpener): check archive length first.

This commit is contained in:
morkt 2016-02-26 22:22:00 +04:00
parent f26bc064c9
commit 73abbbb831

View File

@ -140,12 +140,13 @@ namespace GameRes.Formats.Malie
public override ArcFile TryOpen (ArcView file) public override ArcFile TryOpen (ArcView file)
{ {
if (file.MaxOffset <= 0x10)
return null;
var header = new byte[0x10]; var header = new byte[0x10];
foreach (var key in KnownKeys.Values) foreach (var key in KnownKeys.Values)
{ {
var encryption = new Camellia (key); var encryption = new Camellia (key);
if (0x10 != ReadEncrypted (file.View, encryption, 0, header, 0, 0x10)) ReadEncrypted (file.View, encryption, 0, header, 0, 0x10);
continue;
LibIndexReader reader; LibIndexReader reader;
if (Binary.AsciiEqual (header, 0, "LIBP")) if (Binary.AsciiEqual (header, 0, "LIBP"))
reader = new LibPReader (file, encryption, header); reader = new LibPReader (file, encryption, header);