mirror of https://github.com/upx/upx.git
src: rename membuffer "Uncompression" to "Decompression"
This commit is contained in:
parent
29762a8a96
commit
e0bf460993
|
@ -305,7 +305,7 @@ static bool check_ucl(const int method, const unsigned expected_c_len) {
|
|||
u_buf.alloc(u_len);
|
||||
memset(u_buf, 0, u_len);
|
||||
c_buf.allocForCompression(u_len, c_extra);
|
||||
d_buf.allocForUncompression(u_len);
|
||||
d_buf.allocForDecompression(u_len);
|
||||
|
||||
c_len = c_buf.getSize() - c_extra;
|
||||
r = upx_ucl_compress(u_buf, u_len, c_buf + c_extra, &c_len, nullptr, method, level, NULL_cconf, &cresult);
|
||||
|
@ -316,6 +316,10 @@ static bool check_ucl(const int method, const unsigned expected_c_len) {
|
|||
if (r != 0 || d_len != u_len) return false;
|
||||
if (memcmp(u_buf, d_buf, u_len) != 0) return false;
|
||||
|
||||
d_len = u_len - 1;
|
||||
r = upx_ucl_decompress(c_buf + c_extra, c_len, d_buf, &d_len, method, nullptr);
|
||||
if (r == 0) return false;
|
||||
|
||||
// TODO: rewrite Packer::findOverlapOverhead() so that we can test it here
|
||||
//unsigned x_len = d_len;
|
||||
//r = upx_ucl_test_overlap(c_buf, u_buf, c_extra, c_len, &x_len, method, nullptr);
|
||||
|
|
|
@ -262,7 +262,7 @@ static bool check_zlib(const int method, const int level, const unsigned expecte
|
|||
u_buf.alloc(u_len);
|
||||
memset(u_buf, 0, u_len);
|
||||
c_buf.allocForCompression(u_len, c_extra);
|
||||
d_buf.allocForUncompression(u_len);
|
||||
d_buf.allocForDecompression(u_len);
|
||||
|
||||
c_len = c_buf.getSize() - c_extra;
|
||||
r = upx_zlib_compress(u_buf, u_len, c_buf + c_extra, &c_len, nullptr, method, level, NULL_cconf, &cresult);
|
||||
|
@ -273,6 +273,10 @@ static bool check_zlib(const int method, const int level, const unsigned expecte
|
|||
if (r != 0 || d_len != u_len) return false;
|
||||
if (memcmp(u_buf, d_buf, u_len) != 0) return false;
|
||||
|
||||
d_len = u_len - 1;
|
||||
r = upx_zlib_decompress(c_buf + c_extra, c_len, d_buf, &d_len, method, nullptr);
|
||||
if (r == 0) return false;
|
||||
|
||||
// TODO: rewrite Packer::findOverlapOverhead() so that we can test it here
|
||||
//unsigned x_len = d_len;
|
||||
//r = upx_zlib_test_overlap(c_buf, u_buf, c_extra, c_len, &x_len, method, nullptr);
|
||||
|
|
|
@ -236,7 +236,7 @@ int PackCom::canUnpack()
|
|||
void PackCom::unpack(OutputFile *fo)
|
||||
{
|
||||
ibuf.alloc(file_size);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
|
||||
// read whole file
|
||||
fi->seek(0,SEEK_SET);
|
||||
|
|
|
@ -416,7 +416,7 @@ void PackDjgpp2::unpack(OutputFile *fo)
|
|||
handleStub(fo);
|
||||
|
||||
ibuf.alloc(ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
|
||||
fi->seek(coff_offset + ph.buf_offset + ph.getPackHeaderSize(), SEEK_SET);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
|
|
|
@ -689,7 +689,7 @@ int PackExe::canUnpack()
|
|||
void PackExe::unpack(OutputFile *fo)
|
||||
{
|
||||
ibuf.alloc(file_size);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
|
||||
// read the file
|
||||
fi->seek(ih.headsize16*16,SEEK_SET);
|
||||
|
|
|
@ -189,7 +189,7 @@ bool PackPs1::getBkupHeader(unsigned char *p, unsigned char *dst)
|
|||
|
||||
if (src && (src->id == '1' && src->len < SZ_IH_BKUP) && dst)
|
||||
{
|
||||
unsigned char *unc_bh = New(unsigned char, MemBuffer::getSizeForUncompression(SZ_IH_BKUP));
|
||||
unsigned char *unc_bh = New(unsigned char, MemBuffer::getSizeForDecompression(SZ_IH_BKUP));
|
||||
|
||||
unsigned sz_bh = SZ_IH_BKUP;
|
||||
int r = upx_decompress((const unsigned char *)&src->ih_bkup, src->len,
|
||||
|
@ -716,7 +716,7 @@ void PackPs1::unpack(OutputFile *fo)
|
|||
const unsigned pad = oh.tx_len - ph.u_len;
|
||||
|
||||
ibuf.alloc(fdata_size > PS_HDR_SIZE ? fdata_size : PS_HDR_SIZE);
|
||||
obuf.allocForUncompression(ph.u_len, pad);
|
||||
obuf.allocForDecompression(ph.u_len, pad);
|
||||
|
||||
fi->seek(PS_HDR_SIZE, SEEK_SET);
|
||||
fi->readx(ibuf, fdata_size);
|
||||
|
|
|
@ -320,7 +320,7 @@ void PackTmt::unpack(OutputFile *fo)
|
|||
Packer::handleStub(fi,fo,adam_offset);
|
||||
|
||||
ibuf.alloc(ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
|
||||
fi->seek(adam_offset + ph.buf_offset + ph.getPackHeaderSize(),SEEK_SET);
|
||||
fi->readx(ibuf,ph.c_len);
|
||||
|
|
|
@ -694,7 +694,7 @@ int PackTos::canUnpack() {
|
|||
|
||||
void PackTos::unpack(OutputFile *fo) {
|
||||
ibuf.alloc(ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
|
||||
fi->seek(FH_SIZE + ph.buf_offset + ph.getPackHeaderSize(), SEEK_SET);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
|
|
|
@ -632,7 +632,7 @@ void PackVmlinuxBase<T>::unpack(OutputFile *fo)
|
|||
ph.c_len = p_note0->sh_size - sizeof(word);
|
||||
ibuf.alloc(ph.c_len);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
decompress(ibuf, obuf, false);
|
||||
fo->write(obuf, ph.u_len);
|
||||
obuf.dealloc();
|
||||
|
@ -644,7 +644,7 @@ void PackVmlinuxBase<T>::unpack(OutputFile *fo)
|
|||
}
|
||||
ibuf.alloc(ph.c_len);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
decompress(ibuf, obuf);
|
||||
|
||||
Filter ft(ph.level);
|
||||
|
@ -661,7 +661,7 @@ void PackVmlinuxBase<T>::unpack(OutputFile *fo)
|
|||
ph.c_len = p_note1->sh_size - sizeof(word);
|
||||
ibuf.alloc(ph.c_len);
|
||||
fi->readx(ibuf, p_note1->sh_size - sizeof(ph.u_len));
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
decompress(ibuf, obuf, false);
|
||||
fo->write(obuf, ph.u_len);
|
||||
obuf.dealloc();
|
||||
|
|
|
@ -687,7 +687,7 @@ void PackVmlinuzI386::unpack(OutputFile *fo)
|
|||
// FIXME: but we could write the uncompressed "vmlinux" image
|
||||
|
||||
ibuf.alloc(ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
|
||||
fi->seek(setup_size + ph.buf_offset + ph.getPackHeaderSize(), SEEK_SET);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
|
@ -1044,7 +1044,7 @@ void PackVmlinuzARMEL::unpack(OutputFile *fo)
|
|||
// FIXME: but we could write the uncompressed "vmlinux" image
|
||||
|
||||
ibuf.alloc(ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
|
||||
fi->seek(setup_size + ph.buf_offset + ph.getPackHeaderSize(), SEEK_SET);
|
||||
fi->readx(ibuf, ph.c_len);
|
||||
|
|
|
@ -756,7 +756,7 @@ void PackWcle::decodeObjectTable()
|
|||
|
||||
void PackWcle::decodeImage()
|
||||
{
|
||||
mb_oimage.allocForUncompression(ph.u_len);
|
||||
mb_oimage.allocForDecompression(ph.u_len);
|
||||
oimage = mb_oimage;
|
||||
|
||||
decompress(iimage + ph.buf_offset + ph.getPackHeaderSize(),oimage);
|
||||
|
|
|
@ -3024,7 +3024,7 @@ void PeFile::unpack0(OutputFile *fo, const ht &ih, ht &oh,
|
|||
checkOverlay(overlay);
|
||||
|
||||
ibuf.alloc(ph.c_len);
|
||||
obuf.allocForUncompression(ph.u_len);
|
||||
obuf.allocForDecompression(ph.u_len);
|
||||
fi->seek(isection[1].rawdataptr - 64 + ph.buf_offset + ph.getPackHeaderSize(),SEEK_SET);
|
||||
fi->readx(ibuf, ibufgood= ph.c_len);
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ unsigned MemBuffer::getSizeForCompression(unsigned uncompressed_size, unsigned e
|
|||
return bytes;
|
||||
}
|
||||
|
||||
unsigned MemBuffer::getSizeForUncompression(unsigned uncompressed_size, unsigned extra) {
|
||||
unsigned MemBuffer::getSizeForDecompression(unsigned uncompressed_size, unsigned extra) {
|
||||
size_t bytes = mem_size(1, uncompressed_size, extra); // check
|
||||
return ACC_ICONV(unsigned, bytes);
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ void MemBuffer::allocForCompression(unsigned uncompressed_size, unsigned extra)
|
|||
alloc(size);
|
||||
}
|
||||
|
||||
void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra) {
|
||||
unsigned size = getSizeForUncompression(uncompressed_size, extra);
|
||||
void MemBuffer::allocForDecompression(unsigned uncompressed_size, unsigned extra) {
|
||||
unsigned size = getSizeForDecompression(uncompressed_size, extra);
|
||||
alloc(size);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,11 +78,11 @@ public:
|
|||
~MemBuffer();
|
||||
|
||||
static unsigned getSizeForCompression(unsigned uncompressed_size, unsigned extra = 0);
|
||||
static unsigned getSizeForUncompression(unsigned uncompressed_size, unsigned extra = 0);
|
||||
static unsigned getSizeForDecompression(unsigned uncompressed_size, unsigned extra = 0);
|
||||
|
||||
void alloc(upx_uint64_t size);
|
||||
void allocForCompression(unsigned uncompressed_size, unsigned extra = 0);
|
||||
void allocForUncompression(unsigned uncompressed_size, unsigned extra = 0);
|
||||
void allocForDecompression(unsigned uncompressed_size, unsigned extra = 0);
|
||||
|
||||
void dealloc();
|
||||
void checkState() const;
|
||||
|
|
Loading…
Reference in New Issue