• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 # Copyright 2018 Google Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16 ################################################################################
17 */
18 
19 /*
20   Usage:
21     python infra/helper.py build_image kimageformats
22     python infra/helper.py build_fuzzers --sanitizer undefined|address|memory kimageformats
23     python infra/helper.py run_fuzzer kimageformats kimgio_[ani|avif|heif|kra|ora|pcx|pic|psd|ras|rgb|tga|xcf]_fuzzer
24 */
25 
26 
27 #include <QBuffer>
28 #include <QCoreApplication>
29 #include <QImage>
30 
31 #include "ani_p.h"
32 #include "avif_p.h"
33 #include "heif_p.h"
34 #include "kra.h"
35 #include "ora.h"
36 #include "pcx_p.h"
37 #include "pic_p.h"
38 #include "psd_p.h"
39 #include "ras_p.h"
40 #include "rgb_p.h"
41 #include "tga_p.h"
42 #include "xcf_p.h"
43 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)44 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
45 {
46     int argc = 0;
47     QCoreApplication a(argc, nullptr);
48 
49     QImageIOHandler* handler = new HANDLER();
50 
51     QImage i;
52     QBuffer b;
53     b.setData((const char *)data, size);
54     b.open(QIODevice::ReadOnly);
55     handler->setDevice(&b);
56     handler->canRead();
57     handler->read(&i);
58 
59     delete handler;
60 
61     return 0;
62 }
63