Skip to content

Commit

Permalink
Changes to get fuzz targets building again after API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jan 25, 2025
1 parent aa31d04 commit 27d2c6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 7 additions & 0 deletions ossfuzz/fls_apfs_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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) {
Expand All @@ -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<LegacyCache*>(img->cache_holder);
delete cache;
img->cache_holder = nullptr;

tsk_img_close(img);

return 0;
Expand Down
8 changes: 1 addition & 7 deletions ossfuzz/mem_img.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <stddef.h>
#include <stdint.h>

#include "tsk/img/legacy_cache.h"
#include "tsk/tsk_tools_i.h"

typedef struct {
Expand Down Expand Up @@ -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_MEM_INFO *>(img_info);

auto cache = static_cast<LegacyCache*>(img_info->cache_holder);
delete cache;
img_info->cache_holder = nullptr;

free(mem_info);
}

Expand All @@ -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;
Expand Down

0 comments on commit 27d2c6f

Please sign in to comment.