Pass and verify original data in all xxx_test_overlap() functions.
This commit is contained in:
parent
c96e8a8c19
commit
2c67875781
@ -182,8 +182,10 @@ int upx_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
int upx_test_overlap ( const upx_bytep buf, unsigned src_off,
|
int upx_test_overlap ( const upx_bytep buf,
|
||||||
unsigned src_len, unsigned* dst_len,
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult )
|
const upx_compress_result_t *cresult )
|
||||||
{
|
{
|
||||||
@ -201,15 +203,15 @@ int upx_test_overlap ( const upx_bytep buf, unsigned src_off,
|
|||||||
}
|
}
|
||||||
#if defined(WITH_LZMA)
|
#if defined(WITH_LZMA)
|
||||||
else if (M_IS_LZMA(method))
|
else if (M_IS_LZMA(method))
|
||||||
r = upx_lzma_test_overlap(buf, src_off, src_len, dst_len, method, cresult);
|
r = upx_lzma_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_NRV)
|
#if defined(WITH_NRV)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_nrv_test_overlap(buf, src_off, src_len, dst_len, method, cresult);
|
r = upx_nrv_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
#if defined(WITH_UCL)
|
#if defined(WITH_UCL)
|
||||||
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
|
||||||
r = upx_ucl_test_overlap(buf, src_off, src_len, dst_len, method, cresult);
|
r = upx_ucl_test_overlap(buf, tbuf, src_off, src_len, dst_len, method, cresult);
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
throwInternalError("unknown decompression method");
|
throwInternalError("unknown decompression method");
|
||||||
|
|||||||
@ -46,8 +46,10 @@ int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
|
int upx_lzma_test_overlap ( const upx_bytep buf,
|
||||||
unsigned src_len, unsigned* dst_len,
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
#endif
|
#endif
|
||||||
@ -65,8 +67,10 @@ int upx_nrv_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
int upx_nrv_test_overlap ( const upx_bytep buf, unsigned src_off,
|
int upx_nrv_test_overlap ( const upx_bytep buf,
|
||||||
unsigned src_len, unsigned* dst_len,
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
#endif
|
#endif
|
||||||
@ -84,8 +88,10 @@ int upx_ucl_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
int upx_ucl_test_overlap ( const upx_bytep buf, unsigned src_off,
|
int upx_ucl_test_overlap ( const upx_bytep buf,
|
||||||
unsigned src_len, unsigned* dst_len,
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
#endif
|
#endif
|
||||||
@ -102,8 +108,10 @@ int upx_zlib_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
int upx_zlib_test_overlap ( const upx_bytep buf, unsigned src_off,
|
int upx_zlib_test_overlap ( const upx_bytep buf,
|
||||||
unsigned src_len, unsigned* dst_len,
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "compress.h"
|
#include "compress.h"
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
|
||||||
void lzma_compress_config_t::reset()
|
void lzma_compress_config_t::reset()
|
||||||
@ -483,44 +484,32 @@ error:
|
|||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// test_overlap
|
// test_overlap - see <ucl/ucl.h> for semantics
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
// from <ucl/ucl.h>:
|
int upx_lzma_test_overlap ( const upx_bytep buf,
|
||||||
// test an overlapping in-place decompression within a buffer:
|
const upx_bytep tbuf,
|
||||||
// - try a virtual decompression from &buf[src_off] -> &buf[0]
|
unsigned src_off, unsigned src_len,
|
||||||
// - no data is actually written
|
unsigned* dst_len,
|
||||||
// - only the bytes at buf[src_off..src_off+src_len-1] will get accessed
|
|
||||||
//
|
|
||||||
// 2007-04-25 However, I do not see any "virtual decompress" function in lzma
|
|
||||||
// that avoids writing the result. Therefore, do an actual decompress.
|
|
||||||
|
|
||||||
int upx_lzma_test_overlap ( const upx_bytep buf, unsigned src_off,
|
|
||||||
unsigned src_len, unsigned* dst_len,
|
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult )
|
const upx_compress_result_t *cresult )
|
||||||
{
|
{
|
||||||
assert(M_IS_LZMA(method));
|
assert(M_IS_LZMA(method));
|
||||||
|
|
||||||
// Note that Packer::verifyOverlappingDecompression() will
|
MemBuffer b(src_off + src_len);
|
||||||
// verify the final result in any case.
|
memcpy(b + src_off, buf + src_off, src_len);
|
||||||
unsigned dlen = *dst_len;
|
unsigned saved_dst_len = *dst_len;
|
||||||
unsigned const overlap_overhead = src_off + src_len - dlen;
|
int r = upx_lzma_decompress(b + src_off, src_len, b, dst_len, method, cresult);
|
||||||
// printf("upx_lzma_test_overlap: %d\n", overlap_overhead);
|
if (r != UPX_E_OK)
|
||||||
|
return r;
|
||||||
upx_bytep const dst = (upx_bytep)malloc(src_off + src_len);
|
if (*dst_len != saved_dst_len)
|
||||||
if (dst) {
|
return UPX_E_ERROR;
|
||||||
upx_bytep const src = &dst[src_off];
|
// NOTE: there is a very tiny possibility that decompression has
|
||||||
// High ends of src and dst are equal (including overlap_overhead.)
|
// succeeded but the data is not restored correctly because of
|
||||||
memcpy(src, &buf[src_off], src_len);
|
// in-place buffer overlapping.
|
||||||
int const rv = upx_lzma_decompress(src, src_len, dst, &dlen,
|
if (tbuf != NULL && memcmp(tbuf, b, *dst_len) != 0)
|
||||||
method, cresult);
|
return UPX_E_ERROR;
|
||||||
free(dst);
|
return UPX_E_OK;
|
||||||
if (UPX_E_OK==rv) {
|
|
||||||
return UPX_E_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return UPX_E_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -228,12 +228,15 @@ int upx_ucl_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
//
|
//
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
int upx_ucl_test_overlap ( const upx_bytep buf, unsigned src_off,
|
int upx_ucl_test_overlap ( const upx_bytep buf,
|
||||||
unsigned src_len, unsigned* dst_len,
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult )
|
const upx_compress_result_t *cresult )
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
UNUSED(tbuf); // not needed for UCL
|
||||||
|
|
||||||
switch (method)
|
switch (method)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "compress.h"
|
#include "compress.h"
|
||||||
|
#include "mem.h"
|
||||||
|
|
||||||
|
|
||||||
void zlib_compress_config_t::reset()
|
void zlib_compress_config_t::reset()
|
||||||
@ -188,45 +189,32 @@ done:
|
|||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// test_overlap
|
// test_overlap - see <ucl/ucl.h> for semantics
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
// from <ucl/ucl.h>:
|
int upx_zlib_test_overlap ( const upx_bytep buf,
|
||||||
// test an overlapping in-place decompression within a buffer:
|
const upx_bytep tbuf,
|
||||||
// - try a virtual decompression from &buf[src_off] -> &buf[0]
|
unsigned src_off, unsigned src_len,
|
||||||
// - no data is actually written
|
unsigned* dst_len,
|
||||||
// - only the bytes at buf[src_off..src_off+src_len-1] will get accessed
|
|
||||||
//
|
|
||||||
// 2007-04-25 However, I do not see any "virtual decompress" function in zlib
|
|
||||||
// that avoids writing the result. Therefore, do an actual decompress.
|
|
||||||
|
|
||||||
int upx_zlib_test_overlap ( const upx_bytep buf, unsigned src_off,
|
|
||||||
unsigned src_len, unsigned* dst_len,
|
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult )
|
const upx_compress_result_t *cresult )
|
||||||
{
|
{
|
||||||
assert(method == M_DEFLATE);
|
assert(method == M_DEFLATE);
|
||||||
|
|
||||||
// Note that Packer::verifyOverlappingDecompression() will
|
MemBuffer b(src_off + src_len);
|
||||||
// verify the final result in any case.
|
memcpy(b + src_off, buf + src_off, src_len);
|
||||||
|
unsigned saved_dst_len = *dst_len;
|
||||||
unsigned dlen = *dst_len;
|
int r = upx_zlib_decompress(b + src_off, src_len, b, dst_len, method, cresult);
|
||||||
//unsigned overlap_overhead = src_off + src_len - dlen;
|
if (r != UPX_E_OK)
|
||||||
//printf("upx_zlib_test_overlap: %d\n", overlap_overhead);
|
return r;
|
||||||
|
if (*dst_len != saved_dst_len)
|
||||||
upx_bytep const dst = (upx_bytep)malloc(src_off + src_len);
|
return UPX_E_ERROR;
|
||||||
if (dst) {
|
// NOTE: there is a very tiny possibility that decompression has
|
||||||
upx_bytep const src = &dst[src_off];
|
// succeeded but the data is not restored correctly because of
|
||||||
// High ends of src and dst are equal (including overlap_overhead.)
|
// in-place buffer overlapping.
|
||||||
memcpy(src, &buf[src_off], src_len);
|
if (tbuf != NULL && memcmp(tbuf, b, *dst_len) != 0)
|
||||||
int const rv = upx_zlib_decompress(src, src_len, dst, &dlen,
|
return UPX_E_ERROR;
|
||||||
method, cresult);
|
return UPX_E_OK;
|
||||||
free(dst);
|
|
||||||
if (UPX_E_OK==rv) {
|
|
||||||
return UPX_E_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return UPX_E_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -779,8 +779,10 @@ int upx_decompress ( const upx_bytep src, unsigned src_len,
|
|||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
int upx_test_overlap ( const upx_bytep buf, unsigned src_off,
|
int upx_test_overlap ( const upx_bytep buf,
|
||||||
unsigned src_len, unsigned* dst_len,
|
const upx_bytep tbuf,
|
||||||
|
unsigned src_off, unsigned src_len,
|
||||||
|
unsigned* dst_len,
|
||||||
int method,
|
int method,
|
||||||
const upx_compress_result_t *cresult );
|
const upx_compress_result_t *cresult );
|
||||||
|
|
||||||
|
|||||||
@ -76,10 +76,11 @@ const int *PackDjgpp2::getFilters() const
|
|||||||
|
|
||||||
|
|
||||||
unsigned PackDjgpp2::findOverlapOverhead(const upx_bytep buf,
|
unsigned PackDjgpp2::findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range,
|
unsigned range,
|
||||||
unsigned upper_limit) const
|
unsigned upper_limit) const
|
||||||
{
|
{
|
||||||
unsigned o = super::findOverlapOverhead(buf, range, upper_limit);
|
unsigned o = super::findOverlapOverhead(buf, tbuf, range, upper_limit);
|
||||||
o = (o + 0x3ff) &~ 0x1ff;
|
o = (o + 0x3ff) &~ 0x1ff;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ protected:
|
|||||||
virtual int readFileHeader();
|
virtual int readFileHeader();
|
||||||
|
|
||||||
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range = 0,
|
unsigned range = 0,
|
||||||
unsigned upper_limit = ~0u) const;
|
unsigned upper_limit = ~0u) const;
|
||||||
virtual void buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
|||||||
@ -67,11 +67,12 @@ const int *PackTmt::getFilters() const
|
|||||||
|
|
||||||
|
|
||||||
unsigned PackTmt::findOverlapOverhead(const upx_bytep buf,
|
unsigned PackTmt::findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range,
|
unsigned range,
|
||||||
unsigned upper_limit) const
|
unsigned upper_limit) const
|
||||||
{
|
{
|
||||||
// make sure the decompressor will be paragraph aligned
|
// make sure the decompressor will be paragraph aligned
|
||||||
unsigned o = super::findOverlapOverhead(buf, range, upper_limit);
|
unsigned o = super::findOverlapOverhead(buf, tbuf, range, upper_limit);
|
||||||
o = ((o + 0x20) &~ 0xf) - (ph.u_len & 0xf);
|
o = ((o + 0x20) &~ 0xf) - (ph.u_len & 0xf);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ protected:
|
|||||||
virtual int readFileHeader();
|
virtual int readFileHeader();
|
||||||
|
|
||||||
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range = 0,
|
unsigned range = 0,
|
||||||
unsigned upper_limit = ~0u) const;
|
unsigned upper_limit = ~0u) const;
|
||||||
virtual void buildLoader(const Filter *ft);
|
virtual void buildLoader(const Filter *ft);
|
||||||
|
|||||||
@ -173,8 +173,10 @@ void PackUnix::pack2(OutputFile *fo, Filter &ft)
|
|||||||
compressWithFilters(&ft, OVERHEAD, NULL_cconf, filter_strategy);
|
compressWithFilters(&ft, OVERHEAD, NULL_cconf, filter_strategy);
|
||||||
|
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
|
const upx_bytep tbuf = NULL;
|
||||||
|
if (ft.id == 0) tbuf = ibuf;
|
||||||
ph.overlap_overhead = OVERHEAD;
|
ph.overlap_overhead = OVERHEAD;
|
||||||
if (!testOverlappingDecompression(obuf, ph.overlap_overhead)) {
|
if (!testOverlappingDecompression(obuf, tbuf, ph.overlap_overhead)) {
|
||||||
// not in-place compressible
|
// not in-place compressible
|
||||||
ph.c_len = ph.u_len;
|
ph.c_len = ph.u_len;
|
||||||
}
|
}
|
||||||
@ -353,8 +355,10 @@ void PackUnix::packExtent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
|
const upx_bytep tbuf = NULL;
|
||||||
|
if (ft == NULL || ft->id == 0) tbuf = ibuf;
|
||||||
ph.overlap_overhead = OVERHEAD;
|
ph.overlap_overhead = OVERHEAD;
|
||||||
if (!testOverlappingDecompression(obuf, ph.overlap_overhead)) {
|
if (!testOverlappingDecompression(obuf, tbuf, ph.overlap_overhead)) {
|
||||||
// not in-place compressible
|
// not in-place compressible
|
||||||
ph.c_len = ph.u_len;
|
ph.c_len = ph.u_len;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -386,13 +386,16 @@ void Packer::decompress(const upx_bytep in, upx_bytep out,
|
|||||||
// overlapping decompression
|
// overlapping decompression
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
bool ph_testOverlappingDecompression(const PackHeader &ph, const upx_bytep buf,
|
bool ph_testOverlappingDecompression(const PackHeader &ph,
|
||||||
|
const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned overlap_overhead)
|
unsigned overlap_overhead)
|
||||||
{
|
{
|
||||||
if (ph.c_len >= ph.u_len)
|
if (ph.c_len >= ph.u_len)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
assert((int)overlap_overhead >= 0);
|
assert((int) overlap_overhead >= 0);
|
||||||
|
assert((int) (ph.u_len + overlap_overhead) >= 0);
|
||||||
|
|
||||||
// Because upx_test_overlap() does not use the asm_fast decompressor
|
// Because upx_test_overlap() does not use the asm_fast decompressor
|
||||||
// we must account for extra 3 bytes that asm_fast does use,
|
// we must account for extra 3 bytes that asm_fast does use,
|
||||||
@ -406,16 +409,17 @@ bool ph_testOverlappingDecompression(const PackHeader &ph, const upx_bytep buf,
|
|||||||
|
|
||||||
unsigned src_off = ph.u_len + overlap_overhead - ph.c_len;
|
unsigned src_off = ph.u_len + overlap_overhead - ph.c_len;
|
||||||
unsigned new_len = ph.u_len;
|
unsigned new_len = ph.u_len;
|
||||||
int r = upx_test_overlap(buf - src_off, src_off,
|
int r = upx_test_overlap(buf - src_off, tbuf,
|
||||||
ph.c_len, &new_len, ph.method, &ph.compress_result);
|
src_off, ph.c_len, &new_len,
|
||||||
|
ph.method, &ph.compress_result);
|
||||||
return (r == UPX_E_OK && new_len == ph.u_len);
|
return (r == UPX_E_OK && new_len == ph.u_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Packer::testOverlappingDecompression(const upx_bytep buf,
|
bool Packer::testOverlappingDecompression(const upx_bytep buf, const upx_bytep tbuf,
|
||||||
unsigned overlap_overhead) const
|
unsigned overlap_overhead) const
|
||||||
{
|
{
|
||||||
return ph_testOverlappingDecompression(ph, buf, overlap_overhead);
|
return ph_testOverlappingDecompression(ph, buf, tbuf, overlap_overhead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -474,6 +478,7 @@ void Packer::verifyOverlappingDecompression(upx_bytep o_ptr, unsigned o_size, Fi
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
unsigned Packer::findOverlapOverhead(const upx_bytep buf,
|
unsigned Packer::findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range,
|
unsigned range,
|
||||||
unsigned upper_limit) const
|
unsigned upper_limit) const
|
||||||
{
|
{
|
||||||
@ -493,8 +498,8 @@ unsigned Packer::findOverlapOverhead(const upx_bytep buf,
|
|||||||
assert(m >= low); assert(m <= high);
|
assert(m >= low); assert(m <= high);
|
||||||
assert(m < overhead || overhead == 0);
|
assert(m < overhead || overhead == 0);
|
||||||
nr++;
|
nr++;
|
||||||
bool success = testOverlappingDecompression(buf, m);
|
bool success = testOverlappingDecompression(buf, tbuf, m);
|
||||||
//printf("testOverlapOverhead: %d %d -> %d\n", nr, m, (int)success);
|
printf("testOverlapOverhead(%d): %d %d: %d -> %d\n", nr, low, high, m, (int)success);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
overhead = m;
|
overhead = m;
|
||||||
@ -1413,7 +1418,7 @@ void Packer::compressWithFilters(upx_bytep i_ptr, unsigned i_len,
|
|||||||
if (ph.c_len + lsize + hdr_c_len <= best_ph.c_len + best_ph_lsize + best_hdr_c_len)
|
if (ph.c_len + lsize + hdr_c_len <= best_ph.c_len + best_ph_lsize + best_hdr_c_len)
|
||||||
{
|
{
|
||||||
// get results
|
// get results
|
||||||
ph.overlap_overhead = findOverlapOverhead(o_tmp, overlap_range);
|
ph.overlap_overhead = findOverlapOverhead(o_tmp, i_ptr, overlap_range);
|
||||||
buildLoader(&ft);
|
buildLoader(&ft);
|
||||||
lsize = getLoaderSize();
|
lsize = getLoaderSize();
|
||||||
assert(lsize > 0);
|
assert(lsize > 0);
|
||||||
|
|||||||
@ -203,9 +203,11 @@ protected:
|
|||||||
// util for verifying overlapping decompresion
|
// util for verifying overlapping decompresion
|
||||||
// non-destructive test
|
// non-destructive test
|
||||||
virtual bool testOverlappingDecompression(const upx_bytep buf,
|
virtual bool testOverlappingDecompression(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned overlap_overhead) const;
|
unsigned overlap_overhead) const;
|
||||||
// non-destructive find
|
// non-destructive find
|
||||||
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
virtual unsigned findOverlapOverhead(const upx_bytep buf,
|
||||||
|
const upx_bytep tbuf,
|
||||||
unsigned range = 0,
|
unsigned range = 0,
|
||||||
unsigned upper_limit = ~0u) const;
|
unsigned upper_limit = ~0u) const;
|
||||||
// destructive decompress + verify
|
// destructive decompress + verify
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user