@@ -502,17 +502,20 @@ static int _pe_iterate_resources(
502
502
503
503
if (struct_fits_in_pe (pe , data_entry , IMAGE_RESOURCE_DATA_ENTRY ))
504
504
{
505
- if (callback (
506
- data_entry ,
507
- * type ,
508
- * id ,
509
- * language ,
510
- type_string ,
511
- name_string ,
512
- lang_string ,
513
- callback_data ) == RESOURCE_CALLBACK_ABORT )
505
+ if (data_entry -> Size > 0 && data_entry -> Size < pe -> data_size )
514
506
{
515
- result = RESOURCE_ITERATOR_ABORTED ;
507
+ if (callback (
508
+ data_entry ,
509
+ * type ,
510
+ * id ,
511
+ * language ,
512
+ type_string ,
513
+ name_string ,
514
+ lang_string ,
515
+ callback_data ) == RESOURCE_CALLBACK_ABORT )
516
+ {
517
+ result = RESOURCE_ITERATOR_ABORTED ;
518
+ }
516
519
}
517
520
}
518
521
}
@@ -716,7 +719,8 @@ static void pe_set_resource_string_or_id(
716
719
}
717
720
else
718
721
{
719
- yr_set_integer (rsrc_int , pe -> object , int_description , pe -> resources );
722
+ if (rsrc_int != -1 )
723
+ yr_set_integer (rsrc_int , pe -> object , int_description , pe -> resources );
720
724
}
721
725
}
722
726
@@ -731,7 +735,7 @@ static int pe_collect_resources(
731
735
PE * pe )
732
736
{
733
737
// Don't collect too many resources.
734
- if (pe -> resources > MAX_RESOURCES )
738
+ if (pe -> resources >= MAX_RESOURCES )
735
739
return RESOURCE_CALLBACK_CONTINUE ;
736
740
737
741
yr_set_integer (
@@ -2007,9 +2011,10 @@ const char* pe_get_section_full_name(
2007
2011
for (uint64_t len = 0 ; fits_in_pe (pe , string , len + 1 ); len ++ )
2008
2012
{
2009
2013
// Prevent sign extension to 32-bits on bytes > 0x7F
2010
- // The result negative integer would cause assert in MSVC debug version of isprint()
2011
- unsigned int one_char = (unsigned char )(string [len ]);
2012
-
2014
+ // The result negative integer would cause assert in MSVC debug version of
2015
+ // isprint()
2016
+ unsigned int one_char = (unsigned char ) (string [len ]);
2017
+
2013
2018
// Valid string
2014
2019
if (one_char == 0 )
2015
2020
{
0 commit comments