1diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt 2index b7fb777..615e955 100644 3--- a/src/cpp/CMakeLists.txt 4+++ b/src/cpp/CMakeLists.txt 5@@ -484,6 +484,11 @@ elseif(NOT EPROSIMA_INSTALLER) 6 endif() 7 endif() 8 9+if(DEFINED ENV{LIB_FUZZING_ENGINE}) 10+ add_executable(fuzz_processCDRMsg rtps/messages/fuzz_processCDRMsg.cpp) 11+ target_link_libraries(fuzz_processCDRMsg ${PROJECT_NAME} $ENV{LIB_FUZZING_ENGINE}) 12+endif() 13+ 14 ############################################################################### 15 # Packaging 16 ############################################################################### 17diff --git a/src/cpp/rtps/messages/MessageReceiver.cpp b/src/cpp/rtps/messages/MessageReceiver.cpp 18index 962ca9b..0e82082 100644 19--- a/src/cpp/rtps/messages/MessageReceiver.cpp 20+++ b/src/cpp/rtps/messages/MessageReceiver.cpp 21@@ -324,7 +324,11 @@ void MessageReceiver::processCDRMsg( 22 23 reset(); 24 25+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 26+ GuidPrefix_t participantGuidPrefix; 27+#else 28 GuidPrefix_t participantGuidPrefix = participant_->getGuid().guidPrefix; 29+#endif 30 dest_guid_prefix_ = participantGuidPrefix; 31 32 msg->pos = 0; //Start reading at 0 33@@ -513,7 +517,9 @@ void MessageReceiver::processCDRMsg( 34 submessage->pos = next_msg_pos; 35 } 36 37+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 38 participant_->assert_remote_participant_liveliness(source_guid_prefix_); 39+#endif 40 } 41 42 bool MessageReceiver::checkRTPSHeader( 43diff --git a/src/cpp/rtps/messages/fuzz_processCDRMsg.cpp b/src/cpp/rtps/messages/fuzz_processCDRMsg.cpp 44new file mode 100644 45index 0000000..6a71817 46--- /dev/null 47+++ b/src/cpp/rtps/messages/fuzz_processCDRMsg.cpp 48@@ -0,0 +1,26 @@ 49+#include <stdio.h> 50+#include <stdlib.h> 51+#include <stdint.h> 52+#include <stdarg.h> 53+#include <string.h> 54+ 55+#include <fastrtps/rtps/messages/MessageReceiver.h> 56+#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h> 57+ 58+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 59+ const eprosima::fastrtps::rtps::Locator_t remoteLocator; 60+ eprosima::fastrtps::rtps::MessageReceiver* rcv = new eprosima::fastrtps::rtps::MessageReceiver(NULL, 4096); 61+ 62+ eprosima::fastrtps::rtps::CDRMessage_t msg(0); 63+ msg.wraps = true; 64+ msg.buffer = const_cast<eprosima::fastrtps::rtps::octet*>(data); 65+ msg.length = size; 66+ msg.max_size = size; 67+ msg.reserved_size = size; 68+ 69+ // TODO: Should we unlock in case UnregisterReceiver is called from callback ? 70+ rcv->processCDRMsg(remoteLocator, &msg); 71+ delete rcv; 72+ return 0; 73+} 74+ 75