Skip to content

Commit c009195

Browse files
committed
Apply stricter sanity checks while parsing PE resources.
Corrupted file `c10a733e4899dbd03d537d7832efa71016f618e9fd1bffa35b8265df359a91f8` was producing tons of invalid resource entries.
1 parent a024154 commit c009195

File tree

1 file changed

+4
-3
lines changed
  • libyara/modules/pe

1 file changed

+4
-3
lines changed

libyara/modules/pe/pe.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,12 @@ static int _pe_iterate_resources(
451451

452452
entry = (PIMAGE_RESOURCE_DIRECTORY_ENTRY) (resource_dir + 1);
453453

454+
if (!fits_in_pe(
455+
pe, entry, total_entries * sizeof(IMAGE_RESOURCE_DIRECTORY_ENTRY)))
456+
return result;
457+
454458
for (i = 0; i < total_entries; i++)
455459
{
456-
if (!struct_fits_in_pe(pe, entry, IMAGE_RESOURCE_DIRECTORY_ENTRY))
457-
break;
458-
459460
switch (rsrc_tree_level)
460461
{
461462
case 0:

0 commit comments

Comments
 (0)