Allow unfilter when verifyOverlappingDecompression, for convenience
in end-to-end checksum. packer.h packer.cpp p_unix.cpp committer: jreiser <jreiser> 1141252960 +0000
This commit is contained in:
+2
-2
@@ -411,8 +411,8 @@ void PackUnix::packExtent(
|
|||||||
// write compressed data
|
// write compressed data
|
||||||
if (ph.c_len < ph.u_len) {
|
if (ph.c_len < ph.u_len) {
|
||||||
fo->write(obuf, ph.c_len);
|
fo->write(obuf, ph.c_len);
|
||||||
// Checks ph.u_adler after decompression but before unfiltering
|
// Checks ph.u_adler after decompression, after unfiltering
|
||||||
verifyOverlappingDecompression();
|
verifyOverlappingDecompression(ft);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fo->write(ibuf, ph.u_len);
|
fo->write(ibuf, ph.u_len);
|
||||||
|
|||||||
+6
-3
@@ -295,7 +295,7 @@ bool Packer::checkFinalCompressionRatio(const OutputFile *fo) const
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
void Packer::decompress(const upx_bytep in, upx_bytep out,
|
void Packer::decompress(const upx_bytep in, upx_bytep out,
|
||||||
bool verify_checksum)
|
bool verify_checksum, Filter *fp)
|
||||||
{
|
{
|
||||||
unsigned adler;
|
unsigned adler;
|
||||||
|
|
||||||
@@ -316,6 +316,9 @@ void Packer::decompress(const upx_bytep in, upx_bytep out,
|
|||||||
// verify checksum of decompressed data
|
// verify checksum of decompressed data
|
||||||
if (verify_checksum)
|
if (verify_checksum)
|
||||||
{
|
{
|
||||||
|
if (fp) {
|
||||||
|
fp->unfilter(out, ph.u_len);
|
||||||
|
}
|
||||||
adler = upx_adler32(out, ph.u_len, ph.saved_u_adler);
|
adler = upx_adler32(out, ph.u_len, ph.saved_u_adler);
|
||||||
if (adler != ph.u_adler)
|
if (adler != ph.u_adler)
|
||||||
throwChecksumError();
|
throwChecksumError();
|
||||||
@@ -355,7 +358,7 @@ bool Packer::testOverlappingDecompression(const upx_bytep buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Packer::verifyOverlappingDecompression()
|
void Packer::verifyOverlappingDecompression(Filter *fp)
|
||||||
{
|
{
|
||||||
assert(ph.c_len < ph.u_len);
|
assert(ph.c_len < ph.u_len);
|
||||||
assert((int)ph.overlap_overhead > 0);
|
assert((int)ph.overlap_overhead > 0);
|
||||||
@@ -381,7 +384,7 @@ void Packer::verifyOverlappingDecompression()
|
|||||||
if (offset + ph.c_len > obuf.getSize())
|
if (offset + ph.c_len > obuf.getSize())
|
||||||
return;
|
return;
|
||||||
memmove(obuf + offset, obuf, ph.c_len);
|
memmove(obuf + offset, obuf, ph.c_len);
|
||||||
decompress(obuf + offset, obuf, true);
|
decompress(obuf + offset, obuf, true, fp);
|
||||||
obuf.checkState();
|
obuf.checkState();
|
||||||
#endif /* !UNUPX */
|
#endif /* !UNUPX */
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -160,8 +160,8 @@ protected:
|
|||||||
// main compression drivers
|
// main compression drivers
|
||||||
virtual bool compress(upx_bytep in, upx_bytep out,
|
virtual bool compress(upx_bytep in, upx_bytep out,
|
||||||
unsigned max_offset = 0, unsigned max_match = 0);
|
unsigned max_offset = 0, unsigned max_match = 0);
|
||||||
virtual void decompress(const upx_bytep in,
|
virtual void decompress(const upx_bytep in, upx_bytep out,
|
||||||
upx_bytep out, bool verify_checksum=true);
|
bool verify_checksum = true, Filter *fp = 0);
|
||||||
virtual bool checkCompressionRatio(unsigned u_len, unsigned c_len) const;
|
virtual bool checkCompressionRatio(unsigned u_len, unsigned c_len) const;
|
||||||
virtual bool checkFinalCompressionRatio(const OutputFile *fo) const;
|
virtual bool checkFinalCompressionRatio(const OutputFile *fo) const;
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ protected:
|
|||||||
unsigned range = 0,
|
unsigned range = 0,
|
||||||
unsigned upper_limit = ~0u) const;
|
unsigned upper_limit = ~0u) const;
|
||||||
// destructive decompress + verify
|
// destructive decompress + verify
|
||||||
virtual void verifyOverlappingDecompression();
|
virtual void verifyOverlappingDecompression(Filter *fp = 0);
|
||||||
|
|
||||||
|
|
||||||
// packheader handling
|
// packheader handling
|
||||||
|
|||||||
Reference in New Issue
Block a user