RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
DummyLJpegDecoder.cpp
Go to the documentation of this file.
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 "adt/Casts.h"
22#include "common/RawImage.h"
26#include "fuzz/Common.h"
27#include "io/Buffer.h"
28#include "io/ByteStream.h"
29#include "io/Endianness.h"
30#include <cassert>
31#include <cstdint>
32#include <cstdio>
33
34extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
35
36namespace {
37
40 ThrowRDE("Success!");
41 }
42
43public:
47
48 void decode() { AbstractLJpegDecoder::decodeSOI(); }
49};
50
51} // namespace
52
53extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
54 assert(Data);
55
56 try {
57 const rawspeed::Buffer b(
61
63
64 DummyLJpegDecoder d(bs, mRaw);
65 d.decode();
66 mRaw->createData();
67
68 // no image data was actually be decoded, so don't check for initialization
69 } catch (const rawspeed::RawspeedException&) { // NOLINT(bugprone-empty-catch)
70 // Exceptions are good, crashes are bad.
71 }
72
73 return 0;
74}
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
#define ThrowRDE(...)
assert(dim.area() >=area)
DummyLJpegDecoder(const rawspeed::ByteStream &bs, const rawspeed::RawImage &img)
AbstractLJpegDecoder(ByteStream bs, RawImage img)
uint32_t size_type
Definition Buffer.h:49
rawspeed::RawImage CreateRawImage(rawspeed::ByteStream &bs)
Definition Common.cpp:31
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
Definition Casts.h:32