summaryrefslogtreecommitdiffstats
path: root/src/file_exe.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_exe.c')
-rw-r--r--src/file_exe.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/file_exe.c b/src/file_exe.c
index fab7e18..819cc69 100644
--- a/src/file_exe.c
+++ b/src/file_exe.c
@@ -119,7 +119,10 @@ static int header_check_exe(const unsigned char *buffer, const unsigned int buff
uint64_t sum=0;
const struct pe_image_section_hdr *pe_image_section=(const struct pe_image_section_hdr*)
((const unsigned char*)pe_hdr + sizeof(struct pe_image_file_hdr) + le16(pe_hdr->SizeOfOptionalHeader));
- for(i=0;i<le16(pe_hdr->NumberOfSections) && (const unsigned char*)pe_image_section < buffer+buffer_size;i++,pe_image_section++)
+ for(i=0;
+ i<le16(pe_hdr->NumberOfSections) &&
+ (const unsigned char*)(pe_image_section+1) <= buffer+buffer_size;
+ i++,pe_image_section++)
{
if(le32(pe_image_section->SizeOfRawData)>0)
{