From afc07503d6d4f0c6df7009e2a94f71f055b418ab Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Fri, 29 Mar 2013 14:21:06 +0100 Subject: [PATCH] - Ifc: limit nesting of IfcComplexProperty's. --- code/IFCLoader.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/code/IFCLoader.cpp b/code/IFCLoader.cpp index 4bec20231..cca41f4a2 100644 --- a/code/IFCLoader.cpp +++ b/code/IFCLoader.cpp @@ -587,7 +587,9 @@ void ProcessProductRepresentation(const IfcProduct& el, aiNode* nd, std::vector< typedef std::map Metadata; // ------------------------------------------------------------------------------------------------ -void ProcessMetadata(const ListOf< Lazy< IfcProperty >, 1, 0 >& set, ConversionData& conv, Metadata& properties, const std::string& prefix = "") +void ProcessMetadata(const ListOf< Lazy< IfcProperty >, 1, 0 >& set, ConversionData& conv, Metadata& properties, + const std::string& prefix = "", + unsigned int nest = 0) { BOOST_FOREACH(const IfcProperty& property, set) { const std::string& key = prefix.length() > 0 ? (prefix + "." + property.Name) : property.Name; @@ -638,7 +640,12 @@ void ProcessMetadata(const ListOf< Lazy< IfcProperty >, 1, 0 >& set, ConversionD properties[key]=ss.str(); } else if (const IfcComplexProperty* const complexProp = property.ToPtr()) { - ProcessMetadata(complexProp->HasProperties, conv, properties, property.Name); + if(nest > 2) { // mostly arbitrary limit to prevent stack overflow vulnerabilities + IFCImporter::LogError("maximum nesting level for IfcComplexProperty reached, skipping this property."); + } + else { + ProcessMetadata(complexProp->HasProperties, conv, properties, key, nest + 1); + } } else { properties[key]="";