1
|
|
/*
|
2
|
|
RawSpeed - RAW file decoder.
|
3
|
|
|
4
|
|
Copyright (C) 2018 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 "decompressors/PanasonicDecompressorV5.h"
|
22
|
|
#include "common/RawImage.h" // for RawImage, RawImageData
|
23
|
|
#include "common/RawspeedException.h" // for RawspeedException
|
24
|
|
#include "fuzz/Common.h" // for CreateRawImage
|
25
|
|
#include "io/Buffer.h" // for Buffer, DataBuffer
|
26
|
|
#include "io/ByteStream.h" // for ByteStream
|
27
|
|
#include "io/Endianness.h" // for Endianness, Endianness::little
|
28
|
|
#include <cassert> // for assert
|
29
|
|
#include <cstdint> // for uint8_t
|
30
|
|
|
31
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
|
32
|
|
|
33
|
0
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
|
34
|
0
|
assert(Data);
|
35
|
|
|
36
|
|
try {
|
37
|
0
|
const rawspeed::Buffer b(Data, Size);
|
38
|
0
|
const rawspeed::DataBuffer db(b, rawspeed::Endianness::little);
|
39
|
0
|
rawspeed::ByteStream bs(db);
|
40
|
|
|
41
|
0
|
rawspeed::RawImage mRaw(CreateRawImage(&bs));
|
42
|
|
|
43
|
0
|
const auto bps = bs.get<uint32_t>();
|
44
|
0
|
rawspeed::ByteStream rawData = bs.getStream(bs.getRemainSize());
|
45
|
|
|
46
|
0
|
rawspeed::PanasonicDecompressorV5 p(mRaw, rawData, bps);
|
47
|
0
|
mRaw->createData();
|
48
|
0
|
p.decompress();
|
49
|
|
|
50
|
0
|
mRaw->checkMemIsInitialized();
|
51
|
0
|
} catch (rawspeed::RawspeedException&) {
|
52
|
|
// Exceptions are good, crashes are bad.
|
53
|
|
}
|
54
|
|
|
55
|
0
|
return 0;
|
56
|
|
}
|