-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fuzzer for security deserializer (#1967)
* fuzz: add fuzzer targeting deserializer in security plugin * fuzz_security_deser: set linker language to cxx
- Loading branch information
1 parent
ac3c750
commit 31a4843
Showing
5 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
project(fuzz_security_deser LANGUAGES C) | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
if(NOT TARGET CycloneDDS::ddsc) | ||
# Find the CycloneDDS package. | ||
find_package(CycloneDDS REQUIRED) | ||
endif() | ||
|
||
add_executable(fuzz_security_deser fuzz_security_deser.c) | ||
target_include_directories( | ||
fuzz_security_deser PRIVATE | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../src/core/ddsi/include>" | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../src/security/core/include>" | ||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../src/security/api/include>") | ||
set_target_properties(fuzz_security_deser PROPERTIES LINKER_LANGUAGE CXX) | ||
target_link_libraries(fuzz_security_deser CycloneDDS::ddsc $ENV{LIB_FUZZING_ENGINE}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <string.h> | ||
#include <dds/security/core/dds_security_serialize.h> | ||
#include <dds/security/core/dds_security_utils.h> | ||
|
||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) | ||
{ | ||
{ | ||
DDS_Security_Deserializer dser = DDS_Security_Deserializer_new(data, size); | ||
DDS_Security_KeyMaterial_AES_GCM_GMAC km; | ||
memset(&km, 0, sizeof(DDS_Security_KeyMaterial_AES_GCM_GMAC)); | ||
DDS_Security_Deserialize_KeyMaterial_AES_GCM_GMAC(dser, &km); | ||
DDS_Security_Deserializer_free(dser); | ||
DDS_Security_KeyMaterial_AES_GCM_GMAC_deinit(&km); | ||
} | ||
|
||
{ | ||
DDS_Security_ParticipantBuiltinTopicData *pbtd = DDS_Security_ParticipantBuiltinTopicData_alloc(); | ||
DDS_Security_SecurityException ex; | ||
DDS_Security_Exception_clean(&ex); | ||
DDS_Security_Deserializer dser = DDS_Security_Deserializer_new(data, size); | ||
DDS_Security_Deserialize_ParticipantBuiltinTopicData(dser, pbtd, &ex); | ||
DDS_Security_Deserializer_free(dser); | ||
DDS_Security_Exception_reset(&ex); | ||
DDS_Security_ParticipantBuiltinTopicData_free(pbtd); | ||
} | ||
|
||
return 0; | ||
} |
Binary file added
BIN
+10 Bytes
...z_security_deser/fuzz_security_deser_seed_corpus/2d324193bb3029278fbc99dcd574f74b9d465296
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters