From fc7c011d1aa182de815ac31906ebc2aa36803bb7 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Mon, 3 Jul 2023 18:34:23 +0200 Subject: Add missing check that section index in get_image_section() is valid Number is stored in NumberOfRvaAndSizes and it may be less than IMAGE_NUMBEROF_DIRECTORY_ENTRIES. --- src/dlfcn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dlfcn.c b/src/dlfcn.c index c4563d2..cb9f9bb 100644 --- a/src/dlfcn.c +++ b/src/dlfcn.c @@ -640,7 +640,7 @@ static BOOL get_image_section( HMODULE module, int index, void **ptr, DWORD *siz if( optionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC ) return FALSE; - if( index < 0 || index >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES ) + if( index < 0 || index >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES || index >= optionalHeader->NumberOfRvaAndSizes ) return FALSE; if( optionalHeader->DataDirectory[index].Size == 0 || optionalHeader->DataDirectory[index].VirtualAddress == 0 ) -- cgit v1.2.3-55-g6feb