Skip to content

Commit

Permalink
Fix bad-free when receiving malformed DATA_FRAG submessage (#4145) (#…
Browse files Browse the repository at this point in the history
…4147)

* Refs #20140: Add regression test

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

* Refs #20140: Fix bad free

Signed-off-by: EduPonz <eduardoponz@eprosima.com>

---------

Signed-off-by: EduPonz <eduardoponz@eprosima.com>
(cherry picked from commit 7157a19)

Co-authored-by: Eduardo Ponz Segrelles <eduardoponz@eprosima.com>
  • Loading branch information
mergify[bot] and EduPonz authored Dec 18, 2023
1 parent 8f48bbc commit ce877eb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cpp/rtps/messages/MessageReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,8 @@ bool MessageReceiver::proc_Submsg_DataFrag(
{
EPROSIMA_LOG_WARNING(RTPS_MSG_IN, IDSTRING "Serialized Payload value invalid or larger than maximum allowed size "
"(" << payload_size << "/" << (msg->length - msg->pos) << ")");
ch.serializedPayload.data = nullptr;
ch.inline_qos.data = nullptr;
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions test/blackbox/common/BlackboxTestsTransportUDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ TEST(TransportUDP, DatagramInjection)
ASSERT_FALSE(receivers.empty());

deliver_datagram_from_file(receivers, "datagrams/16784.bin");
deliver_datagram_from_file(receivers, "datagrams/20140.bin");
}

// Test for ==operator UDPTransportDescriptor is not required as it is an abstract class and in UDPv4 is same method
Expand Down
Binary file added test/blackbox/datagrams/20140.bin
Binary file not shown.

0 comments on commit ce877eb

Please sign in to comment.