mirror of
https://github.com/upx/upx
synced 2025-10-05 19:20:23 +08:00
compressWithFilters(..., inhibit_compression_check=0) // SourceForge bug 3541020
Not good to check compression ratio on every block when blocksize < file_size, as when --force_execve of Elf > 0x80000 bytes.
This commit is contained in:
parent
a6d717cb04
commit
f383629282
|
@ -142,6 +142,7 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
||||||
// ui_total_passes = 0;
|
// ui_total_passes = 0;
|
||||||
|
|
||||||
unsigned remaining = file_size;
|
unsigned remaining = file_size;
|
||||||
|
unsigned n_block = 0;
|
||||||
while (remaining > 0)
|
while (remaining > 0)
|
||||||
{
|
{
|
||||||
// FIXME: disable filters if we have more than one block.
|
// FIXME: disable filters if we have more than one block.
|
||||||
|
@ -170,7 +171,8 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
||||||
// that is, AFTER filtering. We want BEFORE filtering,
|
// that is, AFTER filtering. We want BEFORE filtering,
|
||||||
// so that decompression checks the end-to-end checksum.
|
// so that decompression checks the end-to-end checksum.
|
||||||
unsigned const end_u_adler = upx_adler32(ibuf, ph.u_len, ph.u_adler);
|
unsigned const end_u_adler = upx_adler32(ibuf, ph.u_len, ph.u_adler);
|
||||||
compressWithFilters(&ft, OVERHEAD, NULL_cconf, filter_strategy);
|
compressWithFilters(&ft, OVERHEAD, NULL_cconf, filter_strategy,
|
||||||
|
!!n_block++); // check compression ratio only on first block
|
||||||
|
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
const upx_bytep tbuf = NULL;
|
const upx_bytep tbuf = NULL;
|
||||||
|
|
|
@ -1311,7 +1311,8 @@ void Packer::compressWithFilters(upx_bytep i_ptr, unsigned i_len,
|
||||||
Filter *parm_ft,
|
Filter *parm_ft,
|
||||||
const unsigned overlap_range,
|
const unsigned overlap_range,
|
||||||
const upx_compress_config_t *cconf,
|
const upx_compress_config_t *cconf,
|
||||||
int filter_strategy)
|
int filter_strategy,
|
||||||
|
int inhibit_compression_check)
|
||||||
{
|
{
|
||||||
parm_ft->buf_len = f_len;
|
parm_ft->buf_len = f_len;
|
||||||
// struct copies
|
// struct copies
|
||||||
|
@ -1487,7 +1488,9 @@ void Packer::compressWithFilters(upx_bytep i_ptr, unsigned i_len,
|
||||||
this->ph = best_ph;
|
this->ph = best_ph;
|
||||||
*parm_ft = best_ft;
|
*parm_ft = best_ft;
|
||||||
|
|
||||||
// finally check compression ratio
|
// Finally, check compression ratio.
|
||||||
|
// Might be inhibited when blocksize < file_size, for instance.
|
||||||
|
if (!inhibit_compression_check) {
|
||||||
if (best_ph.c_len + best_ph_lsize >= best_ph.u_len)
|
if (best_ph.c_len + best_ph_lsize >= best_ph.u_len)
|
||||||
throwNotCompressible();
|
throwNotCompressible();
|
||||||
if (!checkCompressionRatio(best_ph.u_len, best_ph.c_len))
|
if (!checkCompressionRatio(best_ph.u_len, best_ph.c_len))
|
||||||
|
@ -1495,6 +1498,7 @@ void Packer::compressWithFilters(upx_bytep i_ptr, unsigned i_len,
|
||||||
|
|
||||||
// postconditions 2)
|
// postconditions 2)
|
||||||
assert(best_ph.overlap_overhead > 0);
|
assert(best_ph.overlap_overhead > 0);
|
||||||
|
}
|
||||||
|
|
||||||
// convenience
|
// convenience
|
||||||
buildLoader(&best_ft);
|
buildLoader(&best_ft);
|
||||||
|
@ -1508,10 +1512,11 @@ void Packer::compressWithFilters(upx_bytep i_ptr, unsigned i_len,
|
||||||
void Packer::compressWithFilters(Filter *ft,
|
void Packer::compressWithFilters(Filter *ft,
|
||||||
const unsigned overlap_range,
|
const unsigned overlap_range,
|
||||||
const upx_compress_config_t *cconf,
|
const upx_compress_config_t *cconf,
|
||||||
int filter_strategy)
|
int filter_strategy,
|
||||||
|
int inhibit_compression_check)
|
||||||
{
|
{
|
||||||
compressWithFilters(ft, overlap_range, cconf, filter_strategy,
|
compressWithFilters(ft, overlap_range, cconf, filter_strategy,
|
||||||
0, 0, 0, NULL, 0);
|
0, 0, 0, NULL, 0, inhibit_compression_check);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1522,7 +1527,8 @@ void Packer::compressWithFilters(Filter *ft,
|
||||||
unsigned filter_off,
|
unsigned filter_off,
|
||||||
unsigned ibuf_off,
|
unsigned ibuf_off,
|
||||||
unsigned obuf_off,
|
unsigned obuf_off,
|
||||||
const upx_bytep hdr_ptr, unsigned hdr_len)
|
const upx_bytep hdr_ptr, unsigned hdr_len,
|
||||||
|
int inhibit_compression_check)
|
||||||
{
|
{
|
||||||
ibuf.checkState(); obuf.checkState();
|
ibuf.checkState(); obuf.checkState();
|
||||||
|
|
||||||
|
@ -1538,7 +1544,8 @@ void Packer::compressWithFilters(Filter *ft,
|
||||||
o_ptr,
|
o_ptr,
|
||||||
f_ptr, f_len,
|
f_ptr, f_len,
|
||||||
hdr_ptr, hdr_len,
|
hdr_ptr, hdr_len,
|
||||||
ft, overlap_range, cconf, filter_strategy);
|
ft, overlap_range, cconf, filter_strategy,
|
||||||
|
inhibit_compression_check);
|
||||||
|
|
||||||
ibuf.checkState(); obuf.checkState();
|
ibuf.checkState(); obuf.checkState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,8 @@ protected:
|
||||||
void compressWithFilters(Filter *ft,
|
void compressWithFilters(Filter *ft,
|
||||||
const unsigned overlap_range,
|
const unsigned overlap_range,
|
||||||
const upx_compress_config_t *cconf,
|
const upx_compress_config_t *cconf,
|
||||||
int filter_strategy = 0);
|
int filter_strategy = 0,
|
||||||
|
int inhibit_compression_check = 0);
|
||||||
void compressWithFilters(Filter *ft,
|
void compressWithFilters(Filter *ft,
|
||||||
const unsigned overlap_range,
|
const unsigned overlap_range,
|
||||||
const upx_compress_config_t *cconf,
|
const upx_compress_config_t *cconf,
|
||||||
|
@ -189,7 +190,8 @@ protected:
|
||||||
unsigned filter_buf_off,
|
unsigned filter_buf_off,
|
||||||
unsigned compress_ibuf_off,
|
unsigned compress_ibuf_off,
|
||||||
unsigned compress_obuf_off,
|
unsigned compress_obuf_off,
|
||||||
const upx_bytep hdr_ptr, unsigned hdr_len);
|
const upx_bytep hdr_ptr, unsigned hdr_len,
|
||||||
|
int inhibit_compression_check = 0);
|
||||||
// real compression driver
|
// real compression driver
|
||||||
void compressWithFilters(upx_bytep i_ptr, unsigned i_len,
|
void compressWithFilters(upx_bytep i_ptr, unsigned i_len,
|
||||||
upx_bytep o_ptr,
|
upx_bytep o_ptr,
|
||||||
|
@ -198,7 +200,8 @@ protected:
|
||||||
Filter *ft,
|
Filter *ft,
|
||||||
const unsigned overlap_range,
|
const unsigned overlap_range,
|
||||||
const upx_compress_config_t *cconf,
|
const upx_compress_config_t *cconf,
|
||||||
int filter_strategy);
|
int filter_strategy,
|
||||||
|
int inhibit_compression_check = 0);
|
||||||
|
|
||||||
// util for verifying overlapping decompresion
|
// util for verifying overlapping decompresion
|
||||||
// non-destructive test
|
// non-destructive test
|
||||||
|
|
Loading…
Reference in New Issue
Block a user