Fix overlap detection for PE unoptimizeReloc()
https://github.com/upx/upx/issues/438 modified: packer.cpp
This commit is contained in:
committed by
Markus F.X.J. Oberhumer
parent
a6296ecd67
commit
a6b5033cf1
+7
-5
@@ -1020,7 +1020,7 @@ unsigned Packer::unoptimizeReloc(upx_byte **in, upx_byte *image,
|
|||||||
}
|
}
|
||||||
jc += dif;
|
jc += dif;
|
||||||
}
|
}
|
||||||
*relocs++ = jc;
|
*relocs++ = jc; // FIXME: range check jc
|
||||||
if (!--relocn) {
|
if (!--relocn) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1028,14 +1028,16 @@ unsigned Packer::unoptimizeReloc(upx_byte **in, upx_byte *image,
|
|||||||
{
|
{
|
||||||
if (bits == 32) {
|
if (bits == 32) {
|
||||||
acc_ua_swab32s(image + jc);
|
acc_ua_swab32s(image + jc);
|
||||||
if (((image + jc) - p) < 4) { // data cannot overlap control
|
if ((unsigned long)(p - (image + jc)) < 4) {
|
||||||
p = image + jc + 4;
|
// data must not overlap control
|
||||||
|
p = 4+ image + jc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (bits == 64) {
|
else if (bits == 64) {
|
||||||
set_be64(image + jc, get_le64(image + jc));
|
set_be64(image + jc, get_le64(image + jc));
|
||||||
if (((image + jc) - p) < 8) { // data cannot overlap control
|
if ((unsigned long)(p - (image + jc)) < 8) {
|
||||||
p = image + jc + 8;
|
// data must not overlap control
|
||||||
|
p = 8+ image + jc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user