Skip to content

Commit

Permalink
Fix parse XML member dynamic type fuzzer issue (#5007)
Browse files Browse the repository at this point in the history
* Refs #21223: Add regression test

Signed-off-by: elianalf <[email protected]>

* Refs #21223: Add fix

Signed-off-by: elianalf <[email protected]>

* Refs #21223: Apply suggestion

Signed-off-by: elianalf <[email protected]>

---------

Signed-off-by: elianalf <[email protected]>
  • Loading branch information
elianalf committed Jul 2, 2024
1 parent 00b127c commit 379da7d
Show file tree
Hide file tree
Showing 3 changed files with 388 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/cpp/xmlparser/XMLDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1635,9 +1635,15 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType(
{
std::vector<uint32_t> boundsArray;
dimensionsToArrayBounds(memberArray, boundsArray);
member = factory->create_array_type(
string_builder->build(),
boundsArray)->build();
DynamicTypeBuilder::_ref_type builder_ = factory->create_array_type(string_builder->build(), boundsArray);
if (nullptr != builder_)
{
member = builder_->build();
}
else
{
member = nullptr;
}
}
}
else if (strncmp(memberType, WSTRING, WSTRING_len) == 0)
Expand Down
1 change: 1 addition & 0 deletions test/unittest/xmlparser/XMLParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ TEST_F(XMLParserTests, regressions)
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21153_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21154_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21181_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21223_profile_bin.xml", root));
Log::Flush();
}

Expand Down
Loading

0 comments on commit 379da7d

Please sign in to comment.