Skip to content

Commit

Permalink
Merge pull request sleuthkit#3172 from joachimmetz/fixfuzztargets
Browse files Browse the repository at this point in the history
Changes to get fuzz targets building again after img_info cache member changes
  • Loading branch information
simsong authored Jan 25, 2025
2 parents 3603942 + 653f72d commit 5a9e833
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ossfuzz/fls_apfs_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
tsk_pool_close(pool);

out_img:
tsk_img_close(img);
img->close(img);

return 0;
}
11 changes: 10 additions & 1 deletion ossfuzz/mem_img.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
#include <stdint.h>

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

typedef struct {
TSK_IMG_INFO img_info;
const uint8_t *data;
size_t size;
LegacyCache *cache;
} IMG_MEM_INFO;

static ssize_t mem_read(TSK_IMG_INFO *img_info, TSK_OFF_T offset, char *buf,
Expand All @@ -46,6 +49,8 @@ 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);

delete mem_info->cache;
free(mem_info);
}

Expand All @@ -65,10 +70,14 @@ TSK_IMG_INFO *mem_open(const uint8_t *data, size_t size) {
img->imgstat = mem_imgstat;
img->size = size;
img->sector_size = 512;

inmemory_img->data = data;
inmemory_img->size = size;
inmemory_img->cache = new LegacyCache();

tsk_img_cache_setup(img, 0, 0);
// tsk_img_cache_setup(img, 0, 0);
img->cache_holder = inmemory_img->cache;
img->cache_read = tsk_img_read_legacy;

return img;
}
Expand Down

0 comments on commit 5a9e833

Please sign in to comment.