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
#ifndef DECODER
22
#error DECODER must be defined
23
#endif
24

25
#include "common/RawspeedException.h" // for RawspeedException
26
#include "decoders/ArwDecoder.h"      // IWYU pragma: keep
27
#include "decoders/Cr2Decoder.h"      // IWYU pragma: keep
28
#include "decoders/DcrDecoder.h"      // IWYU pragma: keep
29
#include "decoders/DcsDecoder.h"      // IWYU pragma: keep
30
#include "decoders/DngDecoder.h"      // IWYU pragma: keep
31
#include "decoders/ErfDecoder.h"      // IWYU pragma: keep
32
#include "decoders/IiqDecoder.h"      // IWYU pragma: keep
33
#include "decoders/KdcDecoder.h"      // IWYU pragma: keep
34
#include "decoders/MefDecoder.h"      // IWYU pragma: keep
35
#include "decoders/MosDecoder.h"      // IWYU pragma: keep
36
#include "decoders/NefDecoder.h"      // IWYU pragma: keep
37
#include "decoders/OrfDecoder.h"      // IWYU pragma: keep
38
#include "decoders/PefDecoder.h"      // IWYU pragma: keep
39
#include "decoders/RafDecoder.h"      // IWYU pragma: keep
40
#include "decoders/Rw2Decoder.h"      // IWYU pragma: keep
41
#include "decoders/SrwDecoder.h"      // IWYU pragma: keep
42
#include "decoders/ThreefrDecoder.h"  // IWYU pragma: keep
43
#include "io/Buffer.h"                // for Buffer, DataBuffer
44
#include "metadata/CameraMetaData.h"  // for CameraMetaData
45
#include "parsers/TiffParser.h"       // for TiffParser
46
#include <cassert>                    // for assert
47
#include <cstdint>                    // for uint8_t
48
#include <cstdio>                     // for size_t
49
#include <memory>                     // for unique_ptr
50
#include <utility>                    // for move
51

52
static const rawspeed::CameraMetaData metadata{};
53

54
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
55

56
using rawspeed::DECODER;
57

58 0
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
59 0
  assert(Data);
60

61
  try {
62 0
    const rawspeed::Buffer buffer(Data, Size);
63 0
    auto ifd = rawspeed::TiffParser::parse(nullptr, buffer);
64

65
    // ATM do not care if this is the appropriate decoder.
66
    // only check that the check does not crash.
67 0
    (void)DECODER::isAppropriateDecoder(ifd.get(), &buffer);
68

69 0
    auto decoder = std::make_unique<DECODER>(std::move(ifd), &buffer);
70

71 0
    decoder->applyCrop = false;
72 0
    decoder->interpolateBadPixels = false;
73 0
    decoder->failOnUnknown = false;
74
    // decoder->checkSupport(&metadata);
75

76 0
    decoder->decodeRaw();
77 0
    decoder->decodeMetaData(&metadata);
78

79 0
  } catch (rawspeed::RawspeedException&) {
80 0
    return 0;
81
  }
82

83 0
  return 0;
84
}

Read our documentation on viewing source code .

Loading