Skip to content

Commit

Permalink
Fix oss-fuzz 40243 (#2339)
Browse files Browse the repository at this point in the history
* Refs 12736. Added regression test.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs 12736. Fixed issue.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

* Refs 13161. Apply suggestion.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
(cherry picked from commit fc4fade)
  • Loading branch information
MiguelCompany authored and mergify-bot committed Dec 4, 2021
1 parent 1f4a4b9 commit 8ae251f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cpp/rtps/xmlparser/XMLDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ XMLP_ret XMLParser::parseXMLBitmaskDynamicType(
}

const char* name = p_root->Attribute(NAME);
if (nullptr == name)
{
return XMLP_ret::XML_ERROR;
}
p_dynamictypebuilder_t typeBuilder =
types::DynamicTypeBuilderFactory::get_instance()->create_bitmask_builder(bit_bound);
typeBuilder->set_name(name);
Expand Down
7 changes: 7 additions & 0 deletions test/unittest/xmlparser/XMLParserTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ using eprosima::fastrtps::xmlparser::XMLParser;
using eprosima::fastdds::dds::Log;
using eprosima::fastdds::dds::LogConsumer;

TEST_F(XMLParserTests, regressions)
{
std::unique_ptr<BaseNode> root;

EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/12736.xml", root));
}

TEST_F(XMLParserTests, NoFile)
{
std::unique_ptr<BaseNode> root;
Expand Down
Binary file added test/unittest/xmlparser/regressions/12736.xml
Binary file not shown.

0 comments on commit 8ae251f

Please sign in to comment.