Skip to content

Commit

Permalink
Be less strict with parameter lengths (#5225) (#5248)
Browse files Browse the repository at this point in the history
* Be less strict with parameter lengths (#5225)

* Refs #21537. Add regression test for interoperability issue.

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

* Refs #21537. Add regression test for big parameters.

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

* Refs #21537. Fix builtin deserialization length checks.

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

* Refs #21537. Special cases in test.

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

* Refs #21537. Extend test to full non-custom range.

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

* Refs #21537. Extend parameter size to 64K.

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

* Refs #21537. Uncrustify.

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

* Refs #21638. Fix windows warning.

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

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 7b111f9)

# Conflicts:
#	src/cpp/fastdds/core/policy/ParameterSerializer.hpp
#	test/unittest/rtps/builtin/BuiltinDataSerializationTests.cpp

* Fix conflicts

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

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
mergify[bot] and MiguelCompany authored Nov 4, 2024
1 parent 3691fe3 commit d1b63eb
Show file tree
Hide file tree
Showing 3 changed files with 541 additions and 32 deletions.
32 changes: 16 additions & 16 deletions src/cpp/fastdds/core/policy/ParameterSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ inline bool ParameterSerializer<ParameterLocator_t>::read_content_from_cdr_messa
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_LOCATOR_LENGTH)
if (parameter_length < PARAMETER_LOCATOR_LENGTH)
{
return false;
}
Expand All @@ -273,7 +273,7 @@ inline bool ParameterSerializer<ParameterKey_t>::read_content_from_cdr_message(
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_KEY_HASH_LENGTH)
if (parameter_length < PARAMETER_KEY_HASH_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -343,7 +343,7 @@ inline bool ParameterSerializer<ParameterPort_t>::read_content_from_cdr_message(
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_PORT_LENGTH)
if (parameter_length < PARAMETER_PORT_LENGTH)
{
return false;
}
Expand All @@ -367,7 +367,7 @@ inline bool ParameterSerializer<ParameterGuid_t>::read_content_from_cdr_message(
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_GUID_LENGTH)
if (parameter_length < PARAMETER_GUID_LENGTH)
{
return false;
}
Expand All @@ -394,7 +394,7 @@ inline bool ParameterSerializer<ParameterProtocolVersion_t>::read_content_from_c
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_PROTOCOL_LENGTH)
if (parameter_length < PARAMETER_PROTOCOL_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -422,7 +422,7 @@ inline bool ParameterSerializer<ParameterVendorId_t>::read_content_from_cdr_mess
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_VENDOR_LENGTH)
if (parameter_length < PARAMETER_VENDOR_LENGTH)
{
return false;
}
Expand All @@ -447,7 +447,7 @@ inline bool ParameterSerializer<ParameterIP4Address_t>::read_content_from_cdr_me
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_IP4_LENGTH)
if (parameter_length < PARAMETER_IP4_LENGTH)
{
return false;
}
Expand All @@ -473,7 +473,7 @@ inline bool ParameterSerializer<ParameterBool_t>::read_content_from_cdr_message(
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_BOOL_LENGTH)
if (parameter_length < PARAMETER_BOOL_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -501,7 +501,7 @@ inline bool ParameterSerializer<ParameterStatusInfo_t>::read_content_from_cdr_me
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_STATUS_INFO_LENGTH)
if (parameter_length < PARAMETER_STATUS_INFO_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -530,7 +530,7 @@ inline bool ParameterSerializer<ParameterCount_t>::read_content_from_cdr_message
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_COUNT_LENGTH)
if (parameter_length < PARAMETER_COUNT_LENGTH)
{
return false;
}
Expand All @@ -552,7 +552,7 @@ inline bool ParameterSerializer<ParameterEntityId_t>::read_content_from_cdr_mess
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_ENTITYID_LENGTH)
if (parameter_length < PARAMETER_ENTITYID_LENGTH)
{
return false;
}
Expand All @@ -576,7 +576,7 @@ inline bool ParameterSerializer<ParameterTime_t>::read_content_from_cdr_message(
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_TIME_LENGTH)
if (parameter_length < PARAMETER_TIME_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -604,7 +604,7 @@ inline bool ParameterSerializer<ParameterBuiltinEndpointSet_t>::read_content_fro
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_BUILTINENDPOINTSET_LENGTH)
if (parameter_length < PARAMETER_BUILTINENDPOINTSET_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -761,7 +761,7 @@ inline bool ParameterSerializer<ParameterSampleIdentity_t>::read_content_from_cd
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_SAMPLEIDENTITY_LENGTH)
if (parameter_length < PARAMETER_SAMPLEIDENTITY_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -1039,7 +1039,7 @@ inline bool ParameterSerializer<ParameterParticipantSecurityInfo_t>::read_conten
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_PARTICIPANT_SECURITY_INFO_LENGTH)
if (parameter_length < PARAMETER_PARTICIPANT_SECURITY_INFO_LENGTH)
{
return false;
}
Expand All @@ -1065,7 +1065,7 @@ inline bool ParameterSerializer<ParameterEndpointSecurityInfo_t>::read_content_f
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_ENDPOINT_SECURITY_INFO_LENGTH)
if (parameter_length < PARAMETER_ENDPOINT_SECURITY_INFO_LENGTH)
{
return false;
}
Expand Down
32 changes: 16 additions & 16 deletions src/cpp/fastdds/core/policy/QosPoliciesSerializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline bool QosPoliciesSerializer<DurabilityQosPolicy>::read_content_from_cdr_me
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_KIND_LENGTH)
if (parameter_length < PARAMETER_KIND_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -126,7 +126,7 @@ inline bool QosPoliciesSerializer<DeadlineQosPolicy>::read_content_from_cdr_mess
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_TIME_LENGTH)
if (parameter_length < PARAMETER_TIME_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ inline bool QosPoliciesSerializer<LatencyBudgetQosPolicy>::read_content_from_cdr
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_TIME_LENGTH)
if (parameter_length < PARAMETER_TIME_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ inline bool QosPoliciesSerializer<LivelinessQosPolicy>::read_content_from_cdr_me
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_KIND_LENGTH + PARAMETER_TIME_LENGTH)
if (parameter_length < PARAMETER_KIND_LENGTH + PARAMETER_TIME_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ inline bool QosPoliciesSerializer<ReliabilityQosPolicy>::read_content_from_cdr_m
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_KIND_LENGTH + PARAMETER_TIME_LENGTH)
if (parameter_length < PARAMETER_KIND_LENGTH + PARAMETER_TIME_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -263,7 +263,7 @@ inline bool QosPoliciesSerializer<OwnershipQosPolicy>::read_content_from_cdr_mes
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_KIND_LENGTH)
if (parameter_length < PARAMETER_KIND_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ inline bool QosPoliciesSerializer<DestinationOrderQosPolicy>::read_content_from_
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_KIND_LENGTH)
if (parameter_length < PARAMETER_KIND_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -323,7 +323,7 @@ inline bool QosPoliciesSerializer<ResourceLimitsQosPolicy>::read_content_from_cd
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != 12)
if (parameter_length < 12)
{
return false;
}
Expand Down Expand Up @@ -357,7 +357,7 @@ inline bool QosPoliciesSerializer<TimeBasedFilterQosPolicy>::read_content_from_c
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_TIME_LENGTH)
if (parameter_length < PARAMETER_TIME_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ inline bool QosPoliciesSerializer<PresentationQosPolicy>::read_content_from_cdr_
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_PRESENTATION_LENGTH)
if (parameter_length < PARAMETER_PRESENTATION_LENGTH)
{
return false;
}
Expand Down Expand Up @@ -516,7 +516,7 @@ inline bool QosPoliciesSerializer<HistoryQosPolicy>::read_content_from_cdr_messa
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_KIND_LENGTH + 4)
if (parameter_length < PARAMETER_KIND_LENGTH + 4)
{
return false;
}
Expand Down Expand Up @@ -553,7 +553,7 @@ inline bool QosPoliciesSerializer<DurabilityServiceQosPolicy>::read_content_from
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_TIME_LENGTH + PARAMETER_KIND_LENGTH + 16)
if (parameter_length < PARAMETER_TIME_LENGTH + PARAMETER_KIND_LENGTH + 16)
{
return false;
}
Expand Down Expand Up @@ -588,7 +588,7 @@ inline bool QosPoliciesSerializer<LifespanQosPolicy>::read_content_from_cdr_mess
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_TIME_LENGTH)
if (parameter_length < PARAMETER_TIME_LENGTH)
{
return false;
}
Expand All @@ -615,7 +615,7 @@ inline bool QosPoliciesSerializer<OwnershipStrengthQosPolicy>::read_content_from
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != 4)
if (parameter_length < 4)
{
return false;
}
Expand All @@ -638,7 +638,7 @@ inline bool QosPoliciesSerializer<TransportPriorityQosPolicy>::read_content_from
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != 4)
if (parameter_length < 4)
{
return false;
}
Expand Down Expand Up @@ -800,7 +800,7 @@ inline bool QosPoliciesSerializer<DisablePositiveACKsQosPolicy>::read_content_fr
fastrtps::rtps::CDRMessage_t* cdr_message,
const uint16_t parameter_length)
{
if (parameter_length != PARAMETER_BOOL_LENGTH)
if (parameter_length < PARAMETER_BOOL_LENGTH)
{
return false;
}
Expand Down
Loading

0 comments on commit d1b63eb

Please sign in to comment.