Skip to content

Commit

Permalink
Addres parseXMLMemberDynamicType regression (#5499)
Browse files Browse the repository at this point in the history
* Refs #22484: Add test

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #22484: Fix

Signed-off-by: Mario Dominguez <[email protected]>

---------

Signed-off-by: Mario Dominguez <[email protected]>
(cherry picked from commit 0207274)
  • Loading branch information
Mario-DL authored and mergify[bot] committed Dec 19, 2024
1 parent a00ea62 commit 054f64d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
42 changes: 37 additions & 5 deletions src/cpp/xmlparser/XMLDynamicParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,14 +1309,46 @@ DynamicType::_ref_type XMLParser:: parseXMLMemberDynamicType(

if (!isArray)
{
member = factory->create_sequence_type(content_type, length)->build();
DynamicTypeBuilder::_ref_type inner_builder{factory->create_sequence_type(content_type, length)};
if (nullptr != inner_builder)
{
member = inner_builder->build();
}
else
{
EPROSIMA_LOG_ERROR(XMLPARSER,
"Error parsing sequence element type: Cannot recognize inner content of member: " <<
memberType);
return {};
}
}
else
{
DynamicTypeBuilder::_ref_type inner_builder {factory->create_sequence_type(content_type, length)};
std::vector<uint32_t> bounds;
dimensionsToArrayBounds(memberArray, bounds);
member = factory->create_array_type(inner_builder->build(), bounds)->build();
DynamicTypeBuilder::_ref_type inner_builder{factory->create_sequence_type(content_type, length)};
if (nullptr != inner_builder)
{
std::vector<uint32_t> bounds;
dimensionsToArrayBounds(memberArray, bounds);
DynamicTypeBuilder::_ref_type sub_builder{factory->create_array_type(inner_builder->build(), bounds)};
if (nullptr != sub_builder)
{
member = sub_builder->build();
}
else
{
EPROSIMA_LOG_ERROR(XMLPARSER,
"Error parsing sequence element type: Cannot recognize inner content of member: " <<
memberType);
return {};
}
}
else
{
EPROSIMA_LOG_ERROR(XMLPARSER,
"Error parsing sequence element type: Cannot recognize inner content of member: " <<
memberType);
return {};
}
}
}
else if (p_root->Attribute(MAP_MAXLENGTH) != nullptr)
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 @@ -85,6 +85,7 @@ TEST_F(XMLParserTests, regressions)
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21334_profile_bin.xml", root));
EXPECT_EQ(XMLP_ret::XML_ERROR, XMLParser::loadXML("regressions/21856_profile_bin.xml", root));
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));
Log::Flush();
}

Expand Down
2 changes: 2 additions & 0 deletions test/unittest/xmlparser/regressions/22101_profile_bin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<profiles><topic pr="" />>>�:��<types><type> <typedef type="strigs"uqe����eMaxLengt:="-0a" name="" a�rayDimensions="" />n</type></types>AA�A�<types><type> <typedef ty�������������="string"sequenceMaxLength="-1�����Mua" name="" arrayDimensions="" />sionsion/>n</type></types>A���AAA3D<types><type>y)edef type=""sequenceMaxLength="-255�����Multua" name="" arrayDimensnons="" />sions]on/>n</type></types>A���AAA1D<types><type>y)y�p��������def type=""sequenceMaxLength="(255�����Multica" name="" arrayDimensions="" />sin/>�����Mua" n/>n</type></types>A���AAA3D<types><type>y)y�pe> <typedef type=""sequenceMaxLength="-1�����Multica" name="" arrayDims="" />sionsion/>n</type></types>A���AAA77407812D<types><type>y)y�pe> <typedef type=""sequenceMaxLength="-255�����Multica" name="" arrayDimensions="" />sin/>n</type></types>AA�AAAAAA430097419635D<types><type>2/shm
�d-sC$@Cdtypee="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types>A���AAA1D<types><type>y)y�p��������def type=""sequenceMaxmension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type><type>y)ype> <typedef type="string"sequenceMaxLength="-32769�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA860194839271D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-128�����Multica" name="" arrayDimension="" />sin/>�����Mua" nltica" name="" arra arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA430097419635D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-256�����Multica" data_writerrayDimension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA860194839271D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-255�����Multi���Multica" name="" arrayDimension="" />sin/>�����Mua" naxLengt:="-0a" name="" a�rayDimensions="" />n</type></types>AA�A�<types><type> <typedef ty�������������="string"sequenceMaxLength="-1�����Mua" name="" arrayDimensions="" />sionsion/>n</type></types>A���AAA3D<types><type>y)edef type=""sequenceMaxLength="-255�����Multua" name="" arrayDimensnons="" />sions]on/>n</type></types>A���AAA1D<types><type>y)y�p��������def type=""sequenceMaxLength="(255�����Multica" name="" arrayDimensions="" />sin/>�����Muname="" arrayDimension="" />sin/>�����Mua" nltica" name="" arra arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA430097419635D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-256�����Multica" name="B" arrayDimension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/ame="" arrayDimensio+s="" />sionsion/>n</type></types><profiles>A���AAA32771D</profiles><types><type>y)y�pe� <typedef type=""sequencenceMaxLength="-255�����Multica" name="" arrayDimensions="" />si/> ion/>n</type></types>A���AAA32219729D<types><type>y)y�pe> <typedef type=""sequenceMaxLength="-256�����Multica" name="" arrayDimensions="" />sin/>n</type></types>AA�AAAAAA430097419635D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����M����nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sdquenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sinef type=""sequenceMaxmension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type><type>y)ype> <typedef type="string"sequenceMaxLength="-32769�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA860194839271D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-128�����Multica" name="" arrayDimension="" />sin/>�����Mua" nltica" name="" arra arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA430097419635D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-256�����Multica" name="B" arrayDimension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA860194839271D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-255�����Multi���Multica" name="" arrayDimension="" />sin/>�����Mua" naxLengt:="-0a" name="" a�rayDimensions="" />n</type></types>AA�A�<types><type> <typedef ty�������������="string"sequenceMaxLength="-1�����Mua" name="" arrayDimensions="" />sionsion/>n</type></types>A���AAA3D<types><type>y)edef type=""sequenceMaxLength="-255�����Multua" name="" arrayDimensnons="" />sions]on/>n</type></types>A���AAA1D<types><type>y)y�p��������def type=""sequenceMaxLength="(255�����Multica" name="" arrayDimensions="" />sin/>�����Muname="" arrayDimension="" />sin/>�����Mua" nltica" name="" arra arrayDImension="" />"-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDi>sin/>�����Mua" nltica" name="" arrayDimension="" />sin/ame="" arrayDimensio+s="" />sionsion/>n</type></types><profiles>A���AAA32771D</profiles><types><type>y)y�pe� <typedef type=""sequencenceMaxLength="-255�����Multica" name="" arrayDimensions="" />si/> ion/>n</type></types>A���AAA32219729D<types><type>y)y�pe> <typedef type=""sequenceMaxLength="-255�����Multica" name="" arrayDimensions="" />sin/>n</type></types>AA�AAAAAA430097419635D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-0�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000066�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types><types><type>y)ype> <typedef type="string"sequenceMaxLength="-4295000065�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" /rrayDimensnons="" />sions]on/>n</type></types>A���AAA2D<types><type>y)y�p ������def type=""sequenceMaxmension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type><type>y)ype> <typedef type="string"sequenceMaxLength="-32769�����Multica" name="" arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA860194839271D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-24971358�����Multica" name="" arrayDimension="" />sin/>�����Mua" nltica" name="" arra arrayDImension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/>ca" name="" />sin/>n</type></types>AA�AAAAAA430097419635D<types><type>y)ype> <typedef type="string"sequenceMaxLength="-255�����Multica" name="B" arrayDimension="" />sin/>�����Mua" nltica" name="" arrayDimension="" />sin/ame="" arrayDimensio+s="" />sionsion/>n</type></types><profiles>A���AAA0D</profiles><types><profiles>A���AAA>��������</profiles></types><type>y)y�pe� <typedef type=""sequencenceMaxLength="-255�����Multica" name="" arrayDimensions="" />si/> type=""sequenceMaxLength="(-238�����Multica" name="" arrayDimensions=""�/>sin/>����sion/>n</type><type>>��������</type></profiles>

0 comments on commit 054f64d

Please sign in to comment.