aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2023-07-03 18:34:23 +0200
committerPali Rohár <pali.rohar@gmail.com>2023-07-03 18:34:23 +0200
commitfc7c011d1aa182de815ac31906ebc2aa36803bb7 (patch)
tree95680201f3ee345c0328a8b00b2bc6daac9650db /src
parent9077355238a38f51ebdd3cf116612f02b6cd1a1e (diff)
downloaddlfcn-win32-fc7c011d1aa182de815ac31906ebc2aa36803bb7.tar.gz
dlfcn-win32-fc7c011d1aa182de815ac31906ebc2aa36803bb7.tar.bz2
dlfcn-win32-fc7c011d1aa182de815ac31906ebc2aa36803bb7.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/dlfcn.c2
1 files changed, 1 insertions, 1 deletions
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
640 if( optionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC ) 640 if( optionalHeader->Magic != IMAGE_NT_OPTIONAL_HDR_MAGIC )
641 return FALSE; 641 return FALSE;
642 642
643 if( index < 0 || index >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES ) 643 if( index < 0 || index >= IMAGE_NUMBEROF_DIRECTORY_ENTRIES || index >= optionalHeader->NumberOfRvaAndSizes )
644 return FALSE; 644 return FALSE;
645 645
646 if( optionalHeader->DataDirectory[index].Size == 0 || optionalHeader->DataDirectory[index].VirtualAddress == 0 ) 646 if( optionalHeader->DataDirectory[index].Size == 0 || optionalHeader->DataDirectory[index].VirtualAddress == 0 )