mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Added parm "allow_incompressible" to Packer::{get,read}PackHeader().
This commit is contained in:
parent
4c798c1718
commit
c11e0d02b3
|
@ -684,7 +684,7 @@ int Packer::patchPackHeader(void *b, int blen)
|
|||
}
|
||||
|
||||
|
||||
bool Packer::getPackHeader(void *b, int blen)
|
||||
bool Packer::getPackHeader(void *b, int blen, bool allow_incompressible)
|
||||
{
|
||||
if (!ph.fillPackHeader((unsigned char *)b, blen))
|
||||
return false;
|
||||
|
@ -697,7 +697,9 @@ bool Packer::getPackHeader(void *b, int blen)
|
|||
if (!testUnpackVersion(ph.version))
|
||||
return false;
|
||||
|
||||
if (ph.c_len > ph.u_len || (off_t)ph.c_len >= file_size
|
||||
if (ph.c_len > ph.u_len
|
||||
|| (ph.c_len == ph.u_len && !allow_incompressible)
|
||||
|| (off_t)ph.c_len >= file_size
|
||||
|| ph.version <= 0 || ph.version >= 0xff)
|
||||
throwCantUnpack("header corrupted");
|
||||
else if ((off_t)ph.u_len > ph.u_file_size)
|
||||
|
@ -722,14 +724,14 @@ bool Packer::getPackHeader(void *b, int blen)
|
|||
}
|
||||
|
||||
|
||||
bool Packer::readPackHeader(int len)
|
||||
bool Packer::readPackHeader(int len, bool allow_incompressible)
|
||||
{
|
||||
assert((int)len > 0);
|
||||
MemBuffer buf(len);
|
||||
len = fi->read(buf, len);
|
||||
if (len <= 0)
|
||||
return false;
|
||||
return getPackHeader(buf, len);
|
||||
return getPackHeader(buf, len, allow_incompressible);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -214,8 +214,8 @@ protected:
|
|||
|
||||
// packheader handling
|
||||
virtual int patchPackHeader(void *b, int blen);
|
||||
virtual bool getPackHeader(void *b, int blen);
|
||||
virtual bool readPackHeader(int len);
|
||||
virtual bool getPackHeader(void *b, int blen, bool allow_incompressible=false);
|
||||
virtual bool readPackHeader(int len, bool allow_incompressible=false);
|
||||
virtual void checkAlreadyPacked(const void *b, int blen);
|
||||
|
||||
// loader core
|
||||
|
|
Loading…
Reference in New Issue
Block a user