From 27d2c6fe85335692a75e7d77f8a88f0b55512aad Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Sat, 25 Jan 2025 09:12:17 +0100 Subject: [PATCH] Changes to get fuzz targets building again after API changes --- ossfuzz/fls_apfs_fuzzer.cc | 7 +++++++ ossfuzz/mem_img.h | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ossfuzz/fls_apfs_fuzzer.cc b/ossfuzz/fls_apfs_fuzzer.cc index 80e3db5dce..b655d00b6e 100644 --- a/ossfuzz/fls_apfs_fuzzer.cc +++ b/ossfuzz/fls_apfs_fuzzer.cc @@ -17,6 +17,7 @@ #include "tsk/tsk_tools_i.h" #include "tsk/fs/tsk_fs.h" +#include "tsk/img/legacy_cache.h" #include "tsk/pool/tsk_pool.h" #include "mem_img.h" @@ -30,6 +31,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (img == nullptr) { return 0; } + img->cache_holder = new LegacyCache(); + pool = tsk_pool_open_img_sing(img, 0, TSK_POOL_TYPE_APFS); if (pool == nullptr) { @@ -54,6 +57,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { tsk_pool_close(pool); out_img: + auto cache = static_cast(img->cache_holder); + delete cache; + img->cache_holder = nullptr; + tsk_img_close(img); return 0; diff --git a/ossfuzz/mem_img.h b/ossfuzz/mem_img.h index 55ba1c3a54..375b7cc75b 100644 --- a/ossfuzz/mem_img.h +++ b/ossfuzz/mem_img.h @@ -18,7 +18,6 @@ #include #include -#include "tsk/img/legacy_cache.h" #include "tsk/tsk_tools_i.h" typedef struct { @@ -47,11 +46,6 @@ static ssize_t mem_read(TSK_IMG_INFO *img_info, TSK_OFF_T offset, char *buf, static void mem_close(TSK_IMG_INFO *img_info) { IMG_MEM_INFO *mem_info = reinterpret_cast(img_info); - - auto cache = static_cast(img_info->cache_holder); - delete cache; - img_info->cache_holder = nullptr; - free(mem_info); } @@ -75,7 +69,7 @@ TSK_IMG_INFO *mem_open(const uint8_t *data, size_t size) { inmemory_img->size = size; // tsk_img_cache_setup(img, 0, 0); - img->cache_holder = new LegacyCache(); + img->cache_holder = NULL; img->cache_read = NULL; return img;