Coverage Report

Created: 2026-09-14 06:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/librawspeed/fuzz/rawspeed/main.cpp
Line
Count
Source
1
/*
2
    RawSpeed - RAW file decoder.
3
4
    Copyright (C) 2017 Roman Lebedev
5
6
    This library is free software; you can redistribute it and/or
7
    modify it under the terms of the GNU Lesser General Public
8
    License as published by the Free Software Foundation; either
9
    version 2 of the License, or (at your option) any later version.
10
11
    This library is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
    Lesser General Public License for more details.
15
16
    You should have received a copy of the GNU Lesser General Public
17
    License along with this library; if not, write to the Free Software
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#include "RawSpeed-API.h"
22
#include "adt/Casts.h"
23
#include <cstddef>
24
#include <cstdint>
25
#include <memory>
26
27
static const rawspeed::CameraMetaData metadata{};
28
29
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
30
31
14.9k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
32
  // static const CameraMetaData metadata(RAWSPEED_SOURCE_DIR
33
  // "/data/cameras.xml");
34
35
14.9k
  try {
36
14.9k
    const rawspeed::Buffer buffer(
37
14.9k
        Data, rawspeed::implicit_cast<rawspeed::Buffer::size_type>(Size));
38
14.9k
    rawspeed::RawParser parser(buffer);
39
14.9k
    auto decoder = parser.getDecoder(/*&metadata*/);
40
41
14.9k
    decoder->applyCrop = false;
42
14.9k
    decoder->interpolateBadPixels = false;
43
14.9k
    decoder->failOnUnknown = false;
44
    // decoder->checkSupport(&metadata);
45
46
14.9k
    decoder->decodeRaw();
47
14.9k
    decoder->decodeMetaData(&metadata);
48
14.9k
  } catch (const rawspeed::RawspeedException&) {
49
12.1k
    return 0;
50
12.1k
  }
51
52
2.78k
  return 0;
53
14.9k
}