mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-12 15:45:21 +08:00
Merge pull request #1972 from catenacyber/ossfuzz
Adds fuzz target for oss-fuzz integration
This commit is contained in:
commit
1a7ee7170a
@ -2257,6 +2257,8 @@ IF(ENABLE_TESTS)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ncdap_test/pingurl.c ${CMAKE_CURRENT_BINARY_DIR}/dap4_test/pingurl4.c @ONLY NEWLINE_STYLE LF)
|
||||
ENDIF()
|
||||
|
||||
add_subdirectory(fuzz)
|
||||
|
||||
####
|
||||
# Export files
|
||||
####
|
||||
|
4
fuzz/CMakeLists.txt
Normal file
4
fuzz/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
if(DEFINED ENV{LIB_FUZZING_ENGINE})
|
||||
add_executable(fuzz_open fuzz_open.c)
|
||||
target_link_libraries(fuzz_open netcdf $ENV{LIB_FUZZING_ENGINE})
|
||||
endif()
|
17
fuzz/fuzz_open.c
Normal file
17
fuzz/fuzz_open.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <netcdf.h>
|
||||
#include <netcdf_mem.h>
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||
int ncid;
|
||||
if (nc_open_mem("/tmp/fuzz.nc", 0, Size, (void *) Data, &ncid) == NC_NOERR) {
|
||||
nc_close(ncid);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user