mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
If testOverlappingDecompression() fails, just treat the block as
non-compressible. committer: mfx <mfx> 1036971145 +0000
This commit is contained in:
parent
c798242bfe
commit
a94a3e9741
3
TODO
3
TODO
|
@ -51,9 +51,6 @@ FORMAT DOS/EXE
|
||||||
FORMAT LINUX/386
|
FORMAT LINUX/386
|
||||||
================
|
================
|
||||||
|
|
||||||
- forward-port fix in 1.23: "don't give up too early if a single block
|
|
||||||
turns out to be incompressible"
|
|
||||||
|
|
||||||
- don't mmap() the temporary output file - this seems to improve
|
- don't mmap() the temporary output file - this seems to improve
|
||||||
file io speed
|
file io speed
|
||||||
|
|
||||||
|
|
|
@ -194,23 +194,28 @@ void PackLinuxI386elf::packExtent(
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
ph.overlap_overhead = OVERHEAD;
|
ph.overlap_overhead = OVERHEAD;
|
||||||
if (!testOverlappingDecompression(obuf, ph.overlap_overhead)) {
|
if (!testOverlappingDecompression(obuf, ph.overlap_overhead)) {
|
||||||
throwNotCompressible();
|
// not in-place compressible
|
||||||
|
ph.c_len = ph.u_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (ph.c_len >= ph.u_len) {
|
||||||
ph. c_len = ph.u_len;
|
// block is not compressible
|
||||||
|
ph.c_len = ph.u_len;
|
||||||
// must update checksum of compressed data
|
// must update checksum of compressed data
|
||||||
ph.c_adler = upx_adler32(ibuf, ph.u_len, ph.c_adler);
|
ph.c_adler = upx_adler32(ibuf, ph.u_len, ph.saved_c_adler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write block sizes
|
// write block sizes
|
||||||
b_info tmp; memset(&tmp, 0, sizeof(tmp));
|
b_info tmp;
|
||||||
|
memset(&tmp, 0, sizeof(tmp));
|
||||||
set_native32(&tmp.sz_unc, ph.u_len);
|
set_native32(&tmp.sz_unc, ph.u_len);
|
||||||
set_native32(&tmp.sz_cpr, ph.c_len);
|
set_native32(&tmp.sz_cpr, ph.c_len);
|
||||||
tmp.b_method = ph.method;
|
if (ph.c_len < ph.u_len) {
|
||||||
if (ft) {
|
tmp.b_method = ph.method;
|
||||||
tmp.b_ftid = ft->id;
|
if (ft) {
|
||||||
tmp.b_cto8 = ft->cto;
|
tmp.b_ftid = ft->id;
|
||||||
|
tmp.b_cto8 = ft->cto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fo->write(&tmp, sizeof(tmp));
|
fo->write(&tmp, sizeof(tmp));
|
||||||
b_len += sizeof(b_info);
|
b_len += sizeof(b_info);
|
||||||
|
|
|
@ -163,23 +163,28 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
||||||
|
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
ph.overlap_overhead = OVERHEAD;
|
ph.overlap_overhead = OVERHEAD;
|
||||||
if (!testOverlappingDecompression(obuf, ph.overlap_overhead))
|
if (!testOverlappingDecompression(obuf, ph.overlap_overhead)) {
|
||||||
throwNotCompressible();
|
// not in-place compressible
|
||||||
|
ph.c_len = ph.u_len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (ph.c_len >= ph.u_len) {
|
||||||
// block is not compressible
|
// block is not compressible
|
||||||
ph.c_len = ph.u_len;
|
ph.c_len = ph.u_len;
|
||||||
// must manually update checksum of compressed data
|
// must manually update checksum of compressed data
|
||||||
ph.c_adler = upx_adler32(ibuf, ph.u_len, ph.c_adler);
|
ph.c_adler = upx_adler32(ibuf, ph.u_len, ph.saved_c_adler);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write block header
|
// write block header
|
||||||
b_info blk_info; memset(&blk_info, 0, sizeof(blk_info));
|
b_info blk_info;
|
||||||
|
memset(&blk_info, 0, sizeof(blk_info));
|
||||||
set_native32(&blk_info.sz_unc, ph.u_len);
|
set_native32(&blk_info.sz_unc, ph.u_len);
|
||||||
set_native32(&blk_info.sz_cpr, ph.c_len);
|
set_native32(&blk_info.sz_cpr, ph.c_len);
|
||||||
blk_info.b_method = ph.method;
|
if (ph.c_len < ph.u_len) {
|
||||||
blk_info.b_ftid = ph.filter;
|
blk_info.b_method = ph.method;
|
||||||
blk_info.b_cto8 = ph.filter_cto;
|
blk_info.b_ftid = ph.filter;
|
||||||
|
blk_info.b_cto8 = ph.filter_cto;
|
||||||
|
}
|
||||||
fo->write(&blk_info, sizeof(blk_info));
|
fo->write(&blk_info, sizeof(blk_info));
|
||||||
b_len += sizeof(b_info);
|
b_len += sizeof(b_info);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user