1
0
mirror of https://github.com/upx/upx synced 2025-10-05 19:20:23 +08:00

Added parm "allow_incompressible" to Packer::{get,read}PackHeader().

This commit is contained in:
Markus F.X.J. Oberhumer 2007-04-25 17:33:39 +02:00
parent 4c798c1718
commit c11e0d02b3
2 changed files with 8 additions and 6 deletions

View File

@ -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);
}

View File

@ -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