diff --git a/libyara/modules/pe/pe.c b/libyara/modules/pe/pe.c index d10b311aad..0b563a2f3f 100644 --- a/libyara/modules/pe/pe.c +++ b/libyara/modules/pe/pe.c @@ -849,7 +849,8 @@ static IMPORT_FUNCTION* pe_parse_import_descriptor( while (struct_fits_in_pe(pe, thunks64, IMAGE_THUNK_DATA64) && yr_le64toh(thunks64->u1.Ordinal) != 0 && - parsed_imports < MAX_PE_IMPORTS) + parsed_imports < MAX_PE_IMPORTS && + *num_function_imports < MAX_PE_IMPORTS) { char* name = NULL; uint16_t ordinal = 0; @@ -939,7 +940,8 @@ static IMPORT_FUNCTION* pe_parse_import_descriptor( while (struct_fits_in_pe(pe, thunks32, IMAGE_THUNK_DATA32) && yr_le32toh(thunks32->u1.Ordinal) != 0 && - parsed_imports < MAX_PE_IMPORTS) + parsed_imports < MAX_PE_IMPORTS && + *num_function_imports < MAX_PE_IMPORTS) { char* name = NULL; uint16_t ordinal = 0;