RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
PentaxDecompressor.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
22#include "MemorySanitizer.h"
23#include "adt/Casts.h"
24#include "adt/Optional.h"
25#include "common/RawImage.h"
27#include "fuzz/Common.h"
28#include "io/Buffer.h"
29#include "io/ByteStream.h"
30#include "io/Endianness.h"
31#include <cassert>
32#include <cstdint>
33#include <cstdio>
34
35extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
36
37extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) {
38 assert(Data);
39
40 try {
41 const rawspeed::Buffer b(
45
47
49
50 const bool haveMetadata = bs.get<uint32_t>();
51 if (haveMetadata) {
52 const auto medataLength = bs.get<uint32_t>();
53 metaData = bs.getStream(medataLength);
54 }
55
57
58 rawspeed::PentaxDecompressor p(mRaw, metaData);
59 mRaw->createData();
60 p.decompress(rawData);
61
64 } catch (const rawspeed::RawspeedException&) { // NOLINT(bugprone-empty-catch)
65 // Exceptions are good, crashes are bad.
66 }
67
68 return 0;
69}
assert(dim.area() >=area)
size_type RAWSPEED_READONLY getRemainSize() const
Definition ByteStream.h:87
ByteStream getStream(size_type size_)
Definition ByteStream.h:119
Array2DRef< std::byte > getByteDataAsUncroppedArray2DRef() noexcept
Definition RawImage.h:330
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
rawspeed::RawImage CreateRawImage(rawspeed::ByteStream &bs)
Definition Common.cpp:31
constexpr RAWSPEED_READNONE Ttgt implicit_cast(Tsrc value)
Definition Casts.h:32
static void CheckMemIsInitialized(const void *addr, size_t size)