File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ class DLL_PUBLIC Parser : public LIEF::Parser {
93
93
std::unique_ptr<VectorStream> stream_;
94
94
Binary* binary_;
95
95
PE_TYPE type_;
96
+ std::set<uint32_t > resource_visited_;
96
97
};
97
98
98
99
Original file line number Diff line number Diff line change @@ -273,8 +273,13 @@ ResourceNode* Parser::build_resource_node(
273
273
uint32_t rvaToDirectory = rvaToData & (~ 0x80000000 );
274
274
uint32_t offset = baseOffset + rvaToDirectory;
275
275
try {
276
- const auto * nextDirectoryTable = reinterpret_cast <const pe_resource_directory_table*>(
276
+ const pe_resource_directory_table * nextDirectoryTable = reinterpret_cast <const pe_resource_directory_table*>(
277
277
this ->stream_ ->read (offset, sizeof (pe_resource_directory_table)));
278
+ if (this ->resource_visited_ .count (offset) > 0 ) {
279
+ LOG (WARNING) << " Infinite loop detected on resources" ;
280
+ break ;
281
+ }
282
+ this ->resource_visited_ .insert (offset);
278
283
279
284
ResourceNode* node = this ->build_resource_node (nextDirectoryTable, baseOffset);
280
285
node->id_ = id;
You can’t perform that action at this time.
0 commit comments