ntdll: Add some sanity checks for invalid relocation blocks.
This commit is contained in:
parent
aa68258b7a
commit
8e5f281276
|
@ -1107,8 +1107,14 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
|
|||
rel = (IMAGE_BASE_RELOCATION *)(ptr + relocs->VirtualAddress);
|
||||
end = (IMAGE_BASE_RELOCATION *)(ptr + relocs->VirtualAddress + relocs->Size);
|
||||
|
||||
while (rel < end && rel->SizeOfBlock)
|
||||
while (rel <= end - 1 && rel->SizeOfBlock)
|
||||
{
|
||||
if (rel->VirtualAddress >= total_size)
|
||||
{
|
||||
WARN_(module)( "invalid address %p in relocation %p\n", ptr + rel->VirtualAddress, rel );
|
||||
status = STATUS_ACCESS_VIOLATION;
|
||||
goto error;
|
||||
}
|
||||
rel = LdrProcessRelocationBlock( ptr + rel->VirtualAddress,
|
||||
(rel->SizeOfBlock - sizeof(*rel)) / sizeof(USHORT),
|
||||
(USHORT *)(rel + 1), delta );
|
||||
|
|
Loading…
Reference in New Issue