-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathFujiDecompressor.cpp
More file actions
55 lines (43 loc) · 2.08 KB
/
Copy pathFujiDecompressor.cpp
File metadata and controls
55 lines (43 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
RawSpeed - RAW file decoder.
Copyright (C) 2017 Roman Lebedev
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "decompressors/FujiDecompressor.h" // for FujiDecompressor
#include "common/RawImage.h" // for RawImage
#include "common/RawspeedException.h" // for RawspeedException
#include "fuzz/Common.h" // for CreateRawImage
#include "io/Buffer.h" // for Buffer, DataBuffer
#include "io/ByteStream.h" // for ByteStream
#include "io/Endianness.h" // for Endianness, Endianness::
#include <cassert> // for assert
#include <cstdint> // for uint8_t
#include <cstdio> // for size_t
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
assert(Data);
try {
const rawspeed::Buffer b(Data, Size);
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
rawspeed::ByteStream bs(db);
auto mRaw(CreateRawImage(bs));
mRaw->cfa = CreateCFA(bs);
rawspeed::FujiDecompressor f(mRaw.get(), bs.getStream(bs.getRemainSize()));
mRaw->createData();
f.decompress();
mRaw->checkMemIsInitialized();
} catch (const rawspeed::RawspeedException&) {
// Exceptions are good, crashes are bad.
}
return 0;
}