fixed checking for pkg size

This commit is contained in:
georgemoralis 2023-01-23 19:07:08 +02:00
parent 3396b29136
commit f82a37a0f3
2 changed files with 13 additions and 0 deletions

View File

@ -42,6 +42,16 @@ bool PKG::extract(const std::string& filepath, const std::string& extractPath, s
PKGHeader pkgheader;
file.ReadBE(pkgheader);
if (pkgheader.pkg_size > pkgSize)
{
failreason = "PKG file size is different";
return false;
}
if ((pkgheader.pkg_content_size + pkgheader.pkg_content_offset) > pkgheader.pkg_size)
{
failreason = "Content size is bigger than pkg size";
return false;
}
file.Seek(0, fsSeekSet);
pkg = (U08*)mmap(pkgSize, file.fileDescr());

View File

@ -71,6 +71,9 @@ inline void ReadBE(PKGHeader& s)
ReadBE(s.magic);
ReadBE(s.pkg_table_entry_offset);
ReadBE(s.pkg_table_entry_count);
ReadBE(s.pkg_content_offset);
ReadBE(s.pkg_content_size);
ReadBE(s.pkg_size);
}
struct PKGEntry {