Coverage Report

Created: 2025-07-23 06:40

/src/sleuthkit/ossfuzz/fls_fuzzer.cc
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2020 Google LLC
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <stddef.h>
16
#include <stdint.h>
17
18
#include <memory>
19
20
#include "tsk/tsk_tools_i.h"
21
#include "mem_img.h"
22
23
#ifndef FSTYPE
24
#error Define FSTYPE as a valid value of TSK_FS_TYPE_ENUM.
25
#endif
26
27
3.80k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
28
3.80k
  IMG_INFO *img = mem_open(data, size);
29
3.80k
  if (!img) {
30
0
    return 0;
31
0
  }
32
33
3.80k
  std::unique_ptr<TSK_FS_INFO, decltype(&tsk_fs_close)> fs{
34
3.80k
    tsk_fs_open_img(reinterpret_cast<TSK_IMG_INFO *>(img), 0, FSTYPE),
35
3.80k
    tsk_fs_close
36
3.80k
  };
37
38
3.80k
  if (fs) {
39
2.71k
    tsk_fs_fls(fs.get(), TSK_FS_FLS_FULL, fs->root_inum, TSK_FS_DIR_WALK_FLAG_RECURSE,
40
2.71k
               nullptr, 0);
41
2.71k
  }
42
43
3.80k
  tsk_img_close((TSK_IMG_INFO*)img);
44
45
3.80k
  return 0;
46
3.80k
}