From a94a3e9741e71337e1b5da60d8542ecb4152b9cc Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sun, 10 Nov 2002 23:32:25 +0000 Subject: [PATCH] If testOverlappingDecompression() fails, just treat the block as non-compressible. committer: mfx 1036971145 +0000 --- TODO | 3 --- src/p_lx_elf.cpp | 23 ++++++++++++++--------- src/p_unix.cpp | 21 +++++++++++++-------- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/TODO b/TODO index bd7ed77f..d77ae61b 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 96683b73..f8898d87 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -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); diff --git a/src/p_unix.cpp b/src/p_unix.cpp index 274da86f..cf87087a 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -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);