Skip to content

Commit

Permalink
Fix corner case RTPSParticipantImpl max_data_size < overhead
Browse files Browse the repository at this point in the history
Signed-off-by: Eugenio Collado <[email protected]>
  • Loading branch information
EugenioCollado committed Dec 9, 2024
1 parent a9ad12f commit 549428a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2312,20 +2312,22 @@ uint32_t RTPSParticipantImpl::getMaxDataSize()
uint32_t RTPSParticipantImpl::calculateMaxDataSize(
uint32_t length)
{
uint32_t maxDataSize = length;

// RTPS header
uint32_t overhead = RTPSMESSAGE_HEADER_SIZE;
#if HAVE_SECURITY
// If there is rtps messsage protection, reduce max size for messages,
// because extra data is added on encryption.
if (security_attributes_.is_rtps_protected)
{
maxDataSize -= m_security_manager.calculate_extra_size_for_rtps_message();
overhead += m_security_manager.calculate_extra_size_for_rtps_message();
}
#endif // if HAVE_SECURITY

// RTPS header
maxDataSize -= RTPSMESSAGE_HEADER_SIZE;
return maxDataSize;
if (length <= overhead)
{
return 0;
}
return length - overhead;
}

bool RTPSParticipantImpl::networkFactoryHasRegisteredTransports() const
Expand Down

0 comments on commit 549428a

Please sign in to comment.