fixed checking for pkg size
This commit is contained in:
parent
3396b29136
commit
f82a37a0f3
|
@ -42,6 +42,16 @@ bool PKG::extract(const std::string& filepath, const std::string& extractPath, s
|
||||||
PKGHeader pkgheader;
|
PKGHeader pkgheader;
|
||||||
file.ReadBE(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);
|
file.Seek(0, fsSeekSet);
|
||||||
pkg = (U08*)mmap(pkgSize, file.fileDescr());
|
pkg = (U08*)mmap(pkgSize, file.fileDescr());
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,9 @@ inline void ReadBE(PKGHeader& s)
|
||||||
ReadBE(s.magic);
|
ReadBE(s.magic);
|
||||||
ReadBE(s.pkg_table_entry_offset);
|
ReadBE(s.pkg_table_entry_offset);
|
||||||
ReadBE(s.pkg_table_entry_count);
|
ReadBE(s.pkg_table_entry_count);
|
||||||
|
ReadBE(s.pkg_content_offset);
|
||||||
|
ReadBE(s.pkg_content_size);
|
||||||
|
ReadBE(s.pkg_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PKGEntry {
|
struct PKGEntry {
|
||||||
|
|
Loading…
Reference in New Issue