Fix --brute for p_lx_elf.cpp, which compresses multiple pieces

Force all pieces to use the same de-compressor.
(Future: allow each PT_LOAD to choose its own.)
Has minor wobbles due to page alignment, and size of de-compressor.
64-bit only for now.
https://github.com/upx/upx/issues/570
https://github.com/upx/upx/issues/297
	modified:   p_lx_elf.cpp
	modified:   p_unix.cpp
	modified:   packer.cpp
	modified:   packer.h
This commit is contained in:
John Reiser
2022-03-22 11:46:25 -07:00
committed by Markus F.X.J. Oberhumer
parent 663d6b466b
commit e7ca5c54ff
4 changed files with 150 additions and 34 deletions
+2 -2
View File
@@ -394,7 +394,7 @@ void PackUnix::packExtent(
MemBuffer hdr_obuf;
hdr_obuf.allocForCompression(hdr_u_len);
int r = upx_compress(hdr_ibuf, hdr_u_len, hdr_obuf, &hdr_c_len, nullptr,
ph.method, 10, nullptr, nullptr);
forced_method(ph.method), 10, nullptr, nullptr);
if (r != UPX_E_OK)
throwInternalError("header compression failed");
if (hdr_c_len >= hdr_u_len)
@@ -407,7 +407,7 @@ void PackUnix::packExtent(
memset(&tmp, 0, sizeof(tmp));
set_te32(&tmp.sz_unc, hdr_u_len);
set_te32(&tmp.sz_cpr, hdr_c_len);
tmp.b_method = (unsigned char) ph.method;
tmp.b_method = (unsigned char) forced_method(ph.method);
tmp.b_extra = b_extra;
fo->write(&tmp, sizeof(tmp));
b_len += sizeof(b_info);