diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-23 11:18:44 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-23 11:18:44 +0200 |
| commit | 359422c97cce93bbb27051f9df3efb45bd0b9052 (patch) | |
| tree | 2e352bb852a25390d40d45e199f835d218ad497f /libs/zip/fuzz/fuzz_entry.c | |
| parent | 8ea59863c5d13e68e080cf7612047ea4c655292c (diff) | |
settings file writing
Diffstat (limited to 'libs/zip/fuzz/fuzz_entry.c')
| -rw-r--r-- | libs/zip/fuzz/fuzz_entry.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libs/zip/fuzz/fuzz_entry.c b/libs/zip/fuzz/fuzz_entry.c new file mode 100644 index 0000000..c2c5f0c --- /dev/null +++ b/libs/zip/fuzz/fuzz_entry.c @@ -0,0 +1,38 @@ +#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; +} |
