Skip to content

Commit

Permalink
Pe: fix segmentation fault when parsing a 16 bit DOS binary
Browse files Browse the repository at this point in the history
fix issue #1
  • Loading branch information
Vincent Torri committed Jan 15, 2016
1 parent b29af93 commit 2a879e2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/examine_pe.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ exm_pe_new(const char *filename)
goto del_pe_map;
}

if (dos_header->e_lfanew > exm_map_size_get(pe->map))
{
EXM_LOG_ERR("not a valid PE file (probably 16-bit DOS module)");
goto del_pe_map;
}

pe->nt_header = (IMAGE_NT_HEADERS *)((unsigned char *)dos_header + dos_header->e_lfanew);
if (pe->nt_header->Signature != IMAGE_NT_SIGNATURE)
{
Expand Down

0 comments on commit 2a879e2

Please sign in to comment.