fast-dds: use upstream without patch (#5794)

This commit is contained in:
Catena cyber 2021-05-18 18:30:39 +02:00 committed by GitHub
parent cbc4293c37
commit b7788b5655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 76 deletions

View File

@ -21,6 +21,5 @@ RUN git clone --depth 1 https://github.com/chriskohlhoff/asio/
RUN git clone --depth 1 https://github.com/eProsima/Fast-CDR.git
RUN git clone --depth 1 https://github.com/eProsima/foonathan_memory_vendor.git
RUN git clone --depth 1 https://github.com/eProsima/Fast-DDS.git
COPY patch.diff $SRC
COPY build.sh $SRC
WORKDIR $SRC/Fast-DDS

View File

@ -47,7 +47,6 @@ cmake --build . --target install
)
# build project
git apply ../patch.diff
mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=OFF
make -j $(nproc)

View File

@ -1,74 +0,0 @@
diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
index b7fb777..615e955 100644
--- a/src/cpp/CMakeLists.txt
+++ b/src/cpp/CMakeLists.txt
@@ -484,6 +484,11 @@ elseif(NOT EPROSIMA_INSTALLER)
endif()
endif()
+if(DEFINED ENV{LIB_FUZZING_ENGINE})
+ add_executable(fuzz_processCDRMsg rtps/messages/fuzz_processCDRMsg.cpp)
+ target_link_libraries(fuzz_processCDRMsg ${PROJECT_NAME} $ENV{LIB_FUZZING_ENGINE})
+endif()
+
###############################################################################
# Packaging
###############################################################################
diff --git a/src/cpp/rtps/messages/MessageReceiver.cpp b/src/cpp/rtps/messages/MessageReceiver.cpp
index 962ca9b..0e82082 100644
--- a/src/cpp/rtps/messages/MessageReceiver.cpp
+++ b/src/cpp/rtps/messages/MessageReceiver.cpp
@@ -324,7 +324,11 @@ void MessageReceiver::processCDRMsg(
reset();
+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+ GuidPrefix_t participantGuidPrefix;
+#else
GuidPrefix_t participantGuidPrefix = participant_->getGuid().guidPrefix;
+#endif
dest_guid_prefix_ = participantGuidPrefix;
msg->pos = 0; //Start reading at 0
@@ -513,7 +517,9 @@ void MessageReceiver::processCDRMsg(
submessage->pos = next_msg_pos;
}
+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
participant_->assert_remote_participant_liveliness(source_guid_prefix_);
+#endif
}
bool MessageReceiver::checkRTPSHeader(
diff --git a/src/cpp/rtps/messages/fuzz_processCDRMsg.cpp b/src/cpp/rtps/messages/fuzz_processCDRMsg.cpp
new file mode 100644
index 0000000..6a71817
--- /dev/null
+++ b/src/cpp/rtps/messages/fuzz_processCDRMsg.cpp
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include <fastrtps/rtps/messages/MessageReceiver.h>
+#include <fastdds/rtps/attributes/RTPSParticipantAttributes.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ const eprosima::fastrtps::rtps::Locator_t remoteLocator;
+ eprosima::fastrtps::rtps::MessageReceiver* rcv = new eprosima::fastrtps::rtps::MessageReceiver(NULL, 4096);
+
+ eprosima::fastrtps::rtps::CDRMessage_t msg(0);
+ msg.wraps = true;
+ msg.buffer = const_cast<eprosima::fastrtps::rtps::octet*>(data);
+ msg.length = size;
+ msg.max_size = size;
+ msg.reserved_size = size;
+
+ // TODO: Should we unlock in case UnregisterReceiver is called from callback ?
+ rcv->processCDRMsg(remoteLocator, &msg);
+ delete rcv;
+ return 0;
+}
+