Skip to content

Commit

Permalink
[BUGFIX] In get_virtual_sec_size: protect against div by 0 if section…
Browse files Browse the repository at this point in the history
… alignment is not filled
  • Loading branch information
hasherezade committed May 31, 2023
1 parent 671db94 commit 709a9b4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libpeconv/src/pe_hdrs_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,12 @@ DWORD peconv::get_virtual_sec_size(IN const BYTE* pe_hdr, IN const PIMAGE_SECTIO
//TODO: calculate real size, round up to Virtual Alignment
DWORD alignment = peconv::get_sec_alignment((const PBYTE)pe_hdr, false);
DWORD vsize = sec_hdr->Misc.VirtualSize;
if (alignment != 0) {
DWORD units = vsize / alignment;
if ((vsize % alignment) > 0) units++;

DWORD units = vsize / alignment;
if ((vsize % alignment) > 0) units++;

vsize = units * alignment;

vsize = units * alignment;
}
DWORD image_size = peconv::get_image_size(pe_hdr);
//if it is bigger than the image size, use the size from the headers
if ((sec_hdr->VirtualAddress + vsize) > image_size) {
Expand Down

0 comments on commit 709a9b4

Please sign in to comment.