mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Fixed a rare boundary problem in Packer::compressWithFilters().
The comparision if an update might be possible later was using "<" instead of "<=" which resulted in missing calls to findOverlapOverhead() and buildLoader(). Also, the comparision had not been updated for the newly added hdr_clen fields. This fixes sf.net bug #1477825.
This commit is contained in:
parent
c4f4035072
commit
68f35deb86
|
@ -1422,6 +1422,7 @@ void Packer::compressWithFilters(Filter *parm_ft,
|
|||
ph = orig_ph;
|
||||
ph.method = methods[m];
|
||||
ph.filter = filters[i];
|
||||
ph.overlap_overhead = 0;
|
||||
// get fresh filter
|
||||
Filter ft = orig_ft;
|
||||
ft.init(ph.filter, orig_ft.addvalue);
|
||||
|
@ -1462,11 +1463,12 @@ void Packer::compressWithFilters(Filter *parm_ft,
|
|||
if (compress(ibuf + compress_buf_off, *otemp, max_offset, max_match))
|
||||
{
|
||||
unsigned lsize = 0;
|
||||
if (ph.c_len + lsize < best_ph.c_len + best_ph_lsize)
|
||||
if (ph.c_len + lsize + hdr_clen <= best_ph.c_len + best_ph_lsize + best_hdr_clen)
|
||||
{
|
||||
// get results
|
||||
ph.overlap_overhead = findOverlapOverhead(*otemp, overlap_range);
|
||||
lsize = buildLoader(&ft);
|
||||
assert(lsize > 0);
|
||||
}
|
||||
#if 0
|
||||
printf("\n%2d %02x: %d +%4d +%3d = %d (best: %d +%4d +%3d = %d)\n", ph.method, ph.filter,
|
||||
|
@ -1490,6 +1492,7 @@ void Packer::compressWithFilters(Filter *parm_ft,
|
|||
}
|
||||
if (update)
|
||||
{
|
||||
assert((int)ph.overlap_overhead > 0);
|
||||
// update obuf[] with best version
|
||||
if (otemp != &obuf)
|
||||
memcpy(obuf, *otemp, ph.c_len);
|
||||
|
|
Loading…
Reference in New Issue
Block a user