summaryrefslogtreecommitdiff
path: root/libs/zip/fuzz/fuzz_stream.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/zip/fuzz/fuzz_stream.c')
-rw-r--r--libs/zip/fuzz/fuzz_stream.c40
1 files changed, 0 insertions, 40 deletions
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;
-}