If testOverlappingDecompression() fails, just treat the block as

non-compressible.

committer: mfx <mfx> 1036971145 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2002-11-10 23:32:25 +00:00
parent c798242bfe
commit a94a3e9741
3 changed files with 27 additions and 20 deletions

3
TODO
View File

@ -51,9 +51,6 @@ FORMAT DOS/EXE
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
file io speed

View File

@ -194,23 +194,28 @@ void PackLinuxI386elf::packExtent(
if (ph.c_len < ph.u_len) {
ph.overlap_overhead = OVERHEAD;
if (!testOverlappingDecompression(obuf, ph.overlap_overhead)) {
throwNotCompressible();
// not in-place compressible
ph.c_len = ph.u_len;
}
}
else {
ph. c_len = ph.u_len;
if (ph.c_len >= ph.u_len) {
// block is not compressible
ph.c_len = ph.u_len;
// 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
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_cpr, ph.c_len);
tmp.b_method = ph.method;
if (ft) {
tmp.b_ftid = ft->id;
tmp.b_cto8 = ft->cto;
if (ph.c_len < ph.u_len) {
tmp.b_method = ph.method;
if (ft) {
tmp.b_ftid = ft->id;
tmp.b_cto8 = ft->cto;
}
}
fo->write(&tmp, sizeof(tmp));
b_len += sizeof(b_info);

View File

@ -163,23 +163,28 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
if (ph.c_len < ph.u_len) {
ph.overlap_overhead = OVERHEAD;
if (!testOverlappingDecompression(obuf, ph.overlap_overhead))
throwNotCompressible();
if (!testOverlappingDecompression(obuf, ph.overlap_overhead)) {
// not in-place compressible
ph.c_len = ph.u_len;
}
}
else {
if (ph.c_len >= ph.u_len) {
// block is not compressible
ph.c_len = ph.u_len;
// 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
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_cpr, ph.c_len);
blk_info.b_method = ph.method;
blk_info.b_ftid = ph.filter;
blk_info.b_cto8 = ph.filter_cto;
if (ph.c_len < ph.u_len) {
blk_info.b_method = ph.method;
blk_info.b_ftid = ph.filter;
blk_info.b_cto8 = ph.filter_cto;
}
fo->write(&blk_info, sizeof(blk_info));
b_len += sizeof(b_info);