mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-25 12:24:12 +08:00
(Xp3Opener): additional sanity check when searching archives inside EXE files.
This commit is contained in:
parent
bb55fe7eed
commit
d7ef400a31
@ -315,14 +315,21 @@ NextEntry:
|
|||||||
try {
|
try {
|
||||||
for (byte* ptr = page_begin; ptr != page_end; ++ptr)
|
for (byte* ptr = page_begin; ptr != page_end; ++ptr)
|
||||||
{
|
{
|
||||||
|
// TODO: search every byte only when inside resource section,
|
||||||
|
// otherwise stick to paragraph boundary.
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (ptr[i] == s_xp3_header[i])
|
while (ptr[i] == s_xp3_header[i])
|
||||||
{
|
{
|
||||||
if (++i == s_xp3_header.Length)
|
if (++i == s_xp3_header.Length)
|
||||||
|
{
|
||||||
|
// check whether index offset is non-zero
|
||||||
|
if (0 == *(uint*)(ptr+i))
|
||||||
|
break;
|
||||||
return offset + (ptr - page_begin);
|
return offset + (ptr - page_begin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
view.SafeMemoryMappedViewHandle.ReleasePointer();
|
view.SafeMemoryMappedViewHandle.ReleasePointer();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user