1
0
mirror of https://github.com/upx/upx synced 2025-10-05 19:20:23 +08:00

Try to avoid fatal filter failures by better scanning during the setup phase.

This commit is contained in:
Markus F.X.J. Oberhumer 2006-12-18 16:54:14 +01:00
parent a37a75aecc
commit dde49f0bb4
4 changed files with 34 additions and 13 deletions

View File

@ -58,8 +58,16 @@ static int F(Filter *f)
// must not conflict with the mark.
// Note that unsigned comparison checks both edges of buffer.
for (ic = 0; ic < size - 5; ic++)
if (COND(b,ic) && get_le32(b+ic+1)+ic+1 >= size)
{
if (!COND(b,ic))
continue;
jc = get_le32(b+ic+1)+ic+1;
if (jc < size)
{
if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
return -1;
}
else
buf[b[ic+1]] |= 1;
}
@ -79,8 +87,7 @@ static int F(Filter *f)
// try to detect 'real' calls only
if (jc < size)
{
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
return 1; // fail - buffer not restored
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
#ifdef U
set_be32(b+ic+1,jc+addvalue+cto);
#endif

View File

@ -57,8 +57,16 @@ static int F(Filter *f)
memset(buf,0,256);
for (ic = 0; ic < size - 5; ic++)
if (COND(b,ic,lastcall) && get_le32(b+ic+1)+ic+1 >= size)
{
if (!COND(b,ic,lastcall))
continue;
jc = get_le32(b+ic+1)+ic+1;
if (jc < size)
{
if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
return -1;
}
else
buf[b[ic+1]] |= 1;
}
@ -78,8 +86,7 @@ static int F(Filter *f)
// try to detect 'real' calls only
if (jc < size)
{
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
return 1; // fail - buffer not restored
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
#ifdef U
set_be32(b+ic+1,jc+addvalue+cto);
#endif

View File

@ -58,8 +58,16 @@ static int F(Filter *f)
memset(buf,0,256);
for (ic = 0; ic < size - 5; ic++)
if (COND(b,ic,lastcall,id) && get_le32(b+ic+1)+ic+1 >= size)
{
if (!COND(b,ic,lastcall,id))
continue;
jc = get_le32(b+ic+1)+ic+1;
if (jc < size)
{
if (jc + addvalue >= (1u << 24)) // hi 8 bits won't be cto8
return -1;
}
else
buf[b[ic+1]] |= 1;
}
@ -79,8 +87,7 @@ static int F(Filter *f)
// try to detect 'real' calls only
if (jc < size)
{
if ((1u<<24)<=(jc+addvalue)) // hi 8 bits won't be cto8
return 1; // fail - buffer not restored
assert(jc + addvalue < (1u << 24)); // hi 8 bits won't be cto8
#ifdef U
set_be32(b+ic+1,jc+addvalue+cto);
#endif