From 31016f0d85f215f48deeec0db202e4c247052226 Mon Sep 17 00:00:00 2001 From: Mykyta Mudryi <114981320+nmlsg@users.noreply.github.com> Date: Fri, 15 Sep 2023 11:34:24 +0200 Subject: [PATCH] Delete zip_write_encrypt_pkware_file_fuzzer.cc --- zip_write_encrypt_pkware_file_fuzzer.cc | 61 ------------------------- 1 file changed, 61 deletions(-) delete mode 100644 zip_write_encrypt_pkware_file_fuzzer.cc diff --git a/zip_write_encrypt_pkware_file_fuzzer.cc b/zip_write_encrypt_pkware_file_fuzzer.cc deleted file mode 100644 index 8e9a82920..000000000 --- a/zip_write_encrypt_pkware_file_fuzzer.cc +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#include -#include -#include - -std::string random_string(size_t length); - -#ifdef __cplusplus -extern "C" -#endif - -int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - zip_source_t* src; - zip_t* za; - char buf[32768]; - zip_int64_t i, n; - zip_file_t* f; - - std::string path = random_string(20) + "_pkware"+ ".zip"; - const char *password = "secretpassword"; - const char * file = "file"; - int error = 0; - struct zip *archive = zip_open(path.c_str(), ZIP_CREATE, &error); - - if(error) - return -1; - - struct zip_source *source = zip_source_buffer(archive, data, size, 0); - if(source == NULL){ - printf("failed to create source buffer. %s\n",zip_strerror(archive)); - return -1; - } - - int index = (int)zip_file_add(archive, file, source, ZIP_FL_OVERWRITE); - if(index < 0){ - printf("failed to add file to archive: %s\n",zip_strerror(archive)); - return -1; - } - zip_file_set_encryption(archive, index, ZIP_EM_TRAD_PKWARE,/* Password to encrypt file */ password); - zip_close(archive); - std::remove(path.c_str()); - - return 0; -} - -std::string random_string(size_t length) -{ - auto randchar = []() -> char { - const char charset[] = - "0123456789" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz"; - const size_t max_index = (sizeof(charset) - 1); - return charset[rand() % max_index]; - }; - std::string str(length, 0); - std::generate_n(str.begin(), length, randchar); - return str; -}