summaryrefslogtreecommitdiff
path: root/libs/zip/fuzz
diff options
context:
space:
mode:
Diffstat (limited to 'libs/zip/fuzz')
-rw-r--r--libs/zip/fuzz/CMakeLists.txt24
-rw-r--r--libs/zip/fuzz/build.sh4
-rw-r--r--libs/zip/fuzz/fuzz_entry.c38
-rw-r--r--libs/zip/fuzz/fuzz_stream.c40
4 files changed, 0 insertions, 106 deletions
diff --git a/libs/zip/fuzz/CMakeLists.txt b/libs/zip/fuzz/CMakeLists.txt
deleted file mode 100644
index ab5d8aa..0000000
--- a/libs/zip/fuzz/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# Utilized by OSSFuzz to build the harness(es) for continuous fuzz-testing
-# OSSFuzz defines the following environment variables, that this target relies upon:
-# CXX, CFLAGS, LIB_FUZZING_ENGINE, OUT
-
-set(CMAKE_C_STANDARD 23)
-
-add_definitions(-DNDEBUG) # Do not want assertions
-
-if (DEFINED ENV{CFLAGS})
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}")
-endif ()
-
-add_executable(fuzz_entry fuzz_entry.c)
-target_link_libraries(fuzz_entry PRIVATE ${PROJECT_NAME} $ENV{LIB_FUZZING_ENGINE})
-
-add_executable(fuzz_stream fuzz_stream.c)
-target_link_libraries(fuzz_stream PRIVATE ${PROJECT_NAME} $ENV{LIB_FUZZING_ENGINE})
-
-if (DEFINED ENV{OUT})
- install(TARGETS fuzz_entry DESTINATION $ENV{OUT})
- install(TARGETS fuzz_stream DESTINATION $ENV{OUT})
-else ()
- message(WARNING "Cannot install if $OUT is not defined!")
-endif () \ No newline at end of file
diff --git a/libs/zip/fuzz/build.sh b/libs/zip/fuzz/build.sh
deleted file mode 100644
index b0003ad..0000000
--- a/libs/zip/fuzz/build.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-cd $SRC/zip
-
-mkdir -p build
-cmake -S . -B build -DCMAKE_C_COMPILER_WORKS=1 -DZIP_BUILD_FUZZ=ON && cmake --build build --target install
diff --git a/libs/zip/fuzz/fuzz_entry.c b/libs/zip/fuzz/fuzz_entry.c
deleted file mode 100644
index c2c5f0c..0000000
--- a/libs/zip/fuzz/fuzz_entry.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "zip.h"
-#include <stdint.h>
-#include <stdlib.h>
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, const size_t size) {
- /* Discard inputs larger than 1MB. */
- static const size_t MaxSize = 1024 * 1024;
- if (size < 1 || size > MaxSize) {
- return 0;
- }
-
- void *buf = NULL;
- size_t bufsize = 0;
- struct zip_t *zip = zip_stream_open((const char *)data, size, 0, 'r');
- if (NULL == zip) {
- goto end;
- }
-
- const ssize_t zip_entries_count = zip_entries_total(zip);
-
- if (zip_entries_count <= 0) {
- goto end;
- }
-
- if (0 != zip_entry_openbyindex(zip, 0)) {
- goto end;
- }
-
- zip_entry_read(zip, &buf, &bufsize);
-
-end:
- zip_entry_close(zip);
- if (NULL != zip) {
- zip_close(zip);
- }
- free(buf);
- return 0;
-}
diff --git a/libs/zip/fuzz/fuzz_stream.c b/libs/zip/fuzz/fuzz_stream.c
deleted file mode 100644
index 6c557de..0000000
--- a/libs/zip/fuzz/fuzz_stream.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "zip.h"
-#include <assert.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-int LLVMFuzzerTestOneInput(const uint8_t *data, const size_t size) {
- /* Discard inputs larger than 1MB. */
- static const size_t MaxSize = 1024 * 1024;
- if (size < 1 || size > MaxSize) {
- return 0;
- }
-
- char *outbuf = NULL;
- size_t outbufsize = 0;
- {
- struct zip_t *zip =
- zip_stream_open(NULL, 0, ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
- zip_entry_open(zip, "test");
- zip_entry_write(zip, data, size);
- zip_entry_close(zip);
- zip_stream_copy(zip, (void **)&outbuf, &outbufsize);
- zip_stream_close(zip);
- }
-
- void *inbuf = NULL;
- size_t inbufsize = 0;
- {
- struct zip_t *zip = zip_stream_open(outbuf, outbufsize, 0, 'r');
- zip_entry_open(zip, "test");
- zip_entry_read(zip, &inbuf, &inbufsize);
- zip_entry_close(zip);
- zip_stream_close(zip);
- }
- free(inbuf);
- free(outbuf);
-
- assert(inbufsize == size);
-
- return 0;
-}