Skip to content

Commit

Permalink
Add catch of out-of-range exception for thread settings port (#4461)
Browse files Browse the repository at this point in the history
* Refs #20187: Add catch of out-of-range exception for thread settings port

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>

* Refs #20187: Uncrustify

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>

---------

Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
  • Loading branch information
elianalf authored Feb 29, 2024
1 parent c4dbe83 commit a907798
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cpp/rtps/xmlparser/XMLElementParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4579,6 +4579,14 @@ XMLP_ret XMLParser::getXMLThreadSettingsWithPort(
ret = XMLP_ret::XML_ERROR;
break;
}
catch (const std::out_of_range& except)
{
EPROSIMA_LOG_ERROR(XMLPARSER,
"Value of the port attribute " << attrib->Value() << " out of range. " <<
except.what());
ret = XMLP_ret::XML_ERROR;
break;
}
}
else
{
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 @@ -71,6 +71,7 @@ TEST_F(XMLParserTests, regressions)
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/simple_participant_profiles_nok.xml", root));
EXPECT_EQ(XMLP_ret::XML_OK, XMLParser::loadXML("regressions/simple_participant_profiles_ok.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/20186_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/20187_profile_bin.xml", root));
}

TEST_F(XMLParserTests, NoFile)
Expand Down
1 change: 1 addition & 0 deletions test/unittest/xmlparser/regressions/20187_profile_bin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<log><thread_settings port="88888888888888888884"/></log>

0 comments on commit a907798

Please sign in to comment.