Skip to content

Commit

Permalink
Solve fuzz XMLParser Null-dereference (#5668)
Browse files Browse the repository at this point in the history
* Refs 22843+22844: Regression test

Signed-off-by: Juanjo Garcia <juanjosegarcia@eprosima.com>

* Refs 22843+22844: Fix

Signed-off-by: Juanjo Garcia <juanjosegarcia@eprosima.com>

---------

Signed-off-by: Juanjo Garcia <juanjosegarcia@eprosima.com>
  • Loading branch information
juanjo4936 authored Mar 5, 2025
1 parent b54cb8e commit dc26c40
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cpp/xmlparser/XMLDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,17 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType(

if (!isArray)
{
member = factory->create_map_type(key_type, value_type, length)->build();
auto temp_map = factory->create_map_type(key_type, value_type, length);
if (temp_map)
{
member = temp_map->build();
}
else
{
EPROSIMA_LOG_ERROR(XMLPARSER,
"Error parsing map member with name = " << memberName);
return {};
}
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions test/unittest/xmlparser/XMLParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ TEST_F(XMLParserTests, regressions)
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22054_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22101_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22535_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22843_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/22844_profile_bin.xml", root));
Log::Flush();
}

Expand Down
Loading

0 comments on commit dc26c40

Please sign in to comment.