From e88e5c566f614d884854a59e5986dae659673429 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 3 Dec 2021 08:10:48 +0100 Subject: [PATCH 1/3] Refs 12736. Added regression test. Signed-off-by: Miguel Company --- test/unittest/xmlparser/XMLParserTests.cpp | 7 +++++++ test/unittest/xmlparser/regressions/12736.xml | Bin 0 -> 118 bytes 2 files changed, 7 insertions(+) create mode 100644 test/unittest/xmlparser/regressions/12736.xml diff --git a/test/unittest/xmlparser/XMLParserTests.cpp b/test/unittest/xmlparser/XMLParserTests.cpp index 804a3639876..2fa4e0650e5 100644 --- a/test/unittest/xmlparser/XMLParserTests.cpp +++ b/test/unittest/xmlparser/XMLParserTests.cpp @@ -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 root; + + EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/12736.xml", root)); +} + TEST_F(XMLParserTests, NoFile) { std::unique_ptr root; diff --git a/test/unittest/xmlparser/regressions/12736.xml b/test/unittest/xmlparser/regressions/12736.xml new file mode 100644 index 0000000000000000000000000000000000000000..c0ced7bae818009437c1a36379bb5d4c01474c5c GIT binary patch literal 118 zcmXp?uqml5NG(>d1JibP+wcOQQhhtSVw Date: Fri, 3 Dec 2021 08:11:55 +0100 Subject: [PATCH 2/3] Refs 12736. Fixed issue. Signed-off-by: Miguel Company --- src/cpp/rtps/xmlparser/XMLDynamicParser.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp b/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp index 15a1488c065..830beb4910c 100644 --- a/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp +++ b/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp @@ -606,6 +606,10 @@ XMLP_ret XMLParser::parseXMLBitmaskDynamicType( } const char* name = p_root->Attribute(NAME); + if (!name) + { + return XMLP_ret::XML_ERROR; + } p_dynamictypebuilder_t typeBuilder = types::DynamicTypeBuilderFactory::get_instance()->create_bitmask_builder(bit_bound); typeBuilder->set_name(name); From e78cce8674f40dc2e14782cdcb0cefd0df17e58e Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 3 Dec 2021 13:36:48 +0100 Subject: [PATCH 3/3] Refs 13161. Apply suggestion. Signed-off-by: Miguel Company --- src/cpp/rtps/xmlparser/XMLDynamicParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp b/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp index 830beb4910c..f995fdbd9ce 100644 --- a/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp +++ b/src/cpp/rtps/xmlparser/XMLDynamicParser.cpp @@ -606,7 +606,7 @@ XMLP_ret XMLParser::parseXMLBitmaskDynamicType( } const char* name = p_root->Attribute(NAME); - if (!name) + if (nullptr == name) { return XMLP_ret::XML_ERROR; }