RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
libFuzzer_dummy_main.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 "rawspeedconfig.h"
23#include "adt/Array1DRef.h"
25#include "io/Buffer.h"
26#include "io/FileIOException.h"
27#include "io/FileReader.h"
28#include <algorithm>
29#include <cstdint>
30#include <cstdlib>
31#include <iostream>
32#include <memory>
33#include <string>
34#include <tuple>
35#include <vector>
36
37#ifdef HAVE_OPENMP
38#include <omp.h>
39#endif
40
41extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size);
42
43namespace {
44
45int usage() {
46 std::cout << "This is just a placeholder.\nFor fuzzers to actually function, "
47 "you need to build rawspeed with clang compiler, with FUZZ "
48 "build type.\n";
49
50 return EXIT_SUCCESS;
51}
52
53void process(const char* filename) noexcept {
54 rawspeed::FileReader reader(filename);
55 std::unique_ptr<std::vector<
58 storage;
60
61 try {
62 std::tie(storage, buf) = reader.readFile();
63 } catch (const rawspeed::FileIOException&) {
64 // failed to read the file for some reason.
65 // just ignore it.
66 return;
67 }
68
70}
71
72} // namespace
73
74int main(int argc_, char** argv_) {
75 auto argv = rawspeed::Array1DRef(argv_, argc_);
76
77 if (1 == argv.size() ||
78 (2 == argv.size() && std::string("-help=1") == argv(1)))
79 return usage();
80
81#ifdef HAVE_OPENMP
82 const auto corpusCount = argv.size() - 1;
83 auto chunkSize = (corpusCount / (10 * omp_get_num_threads()));
84 chunkSize = std::max(chunkSize, 1);
85#pragma omp parallel for default(none) firstprivate(argv, chunkSize) \
86 schedule(dynamic, chunkSize)
87#endif
88 for (int i = 1; i < argv.size(); ++i)
89 process(argv(i));
90
91 return EXIT_SUCCESS;
92}
const uint8_t * begin() const
Definition Buffer.h:99
size_type RAWSPEED_READONLY getSize() const
Definition Buffer.h:115
std::pair< std::unique_ptr< std::vector< uint8_t, DefaultInitAllocatorAdaptor< uint8_t, AlignedAllocator< uint8_t, 16 > > > >, Buffer > readFile() const
int main()
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition Dual.cpp:161
void process(const char *filename) noexcept
Array1DRef(T *data_, int numElts_) -> Array1DRef< T >