mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
fixed reading of AST index with zero-length entries.
This commit is contained in:
parent
0833259e3b
commit
a1ac261ce7
@ -2,7 +2,7 @@
|
|||||||
//! \date Tue Apr 21 02:24:20 2015
|
//! \date Tue Apr 21 02:24:20 2015
|
||||||
//! \brief AST script engine resource archives.
|
//! \brief AST script engine resource archives.
|
||||||
//
|
//
|
||||||
// Copyright (C) 2015 by morkt
|
// Copyright (C) 2015-2016 by morkt
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
// of this software and associated documentation files (the "Software"), to
|
// of this software and associated documentation files (the "Software"), to
|
||||||
@ -73,27 +73,35 @@ namespace GameRes.Formats.AST
|
|||||||
if (name_length > name_buf.Length)
|
if (name_length > name_buf.Length)
|
||||||
name_buf = new byte[name_length];
|
name_buf = new byte[name_length];
|
||||||
file.View.Read (index_offset+9, name_buf, 0, (uint)name_length);
|
file.View.Read (index_offset+9, name_buf, 0, (uint)name_length);
|
||||||
if (2 == version)
|
|
||||||
for (int j = 0; j < name_length; ++j)
|
|
||||||
name_buf[j] ^= 0xff;
|
|
||||||
if (i+1 == count)
|
if (i+1 == count)
|
||||||
next_offset = (uint)file.MaxOffset;
|
next_offset = (uint)file.MaxOffset;
|
||||||
else
|
else
|
||||||
next_offset = file.View.ReadUInt32 (index_offset+9+name_length);
|
next_offset = file.View.ReadUInt32 (index_offset+9+name_length);
|
||||||
if (next_offset < offset)
|
if (0 != offset && offset != file.MaxOffset)
|
||||||
return null;
|
|
||||||
string name = Encodings.cp932.GetString (name_buf, 0, name_length);
|
|
||||||
var entry = new PackedEntry
|
|
||||||
{
|
{
|
||||||
Name = name,
|
if (2 == version)
|
||||||
Type = FormatCatalog.Instance.GetTypeFromName (name),
|
for (int j = 0; j < name_length; ++j)
|
||||||
Offset = offset,
|
name_buf[j] ^= 0xff;
|
||||||
Size = next_offset - offset,
|
uint packed_size;
|
||||||
UnpackedSize = size,
|
if (0 == next_offset)
|
||||||
};
|
packed_size = size;
|
||||||
if (!entry.CheckPlacement (file.MaxOffset))
|
else if (next_offset >= offset)
|
||||||
return null;
|
packed_size = next_offset - offset;
|
||||||
dir.Add (entry);
|
else
|
||||||
|
return null;
|
||||||
|
string name = Encodings.cp932.GetString (name_buf, 0, name_length);
|
||||||
|
var entry = new PackedEntry
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
Type = FormatCatalog.Instance.GetTypeFromName (name),
|
||||||
|
Offset = offset,
|
||||||
|
Size = packed_size,
|
||||||
|
UnpackedSize = size,
|
||||||
|
};
|
||||||
|
if (!entry.CheckPlacement (file.MaxOffset))
|
||||||
|
return null;
|
||||||
|
dir.Add (entry);
|
||||||
|
}
|
||||||
index_offset += 9 + name_length;
|
index_offset += 9 + name_length;
|
||||||
}
|
}
|
||||||
if (2 == version)
|
if (2 == version)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user