Line | Count | Source |
1 | | /* |
2 | | # SPDX-FileCopyrightText: 2019 Google Inc. |
3 | | # SPDX-FileCopyrightText: 2025 Azhar Momin <azhar.momin@kdemail.net> |
4 | | # SPDX-License-Identifier: Apache-2.0 |
5 | | # |
6 | | # Copyright 2019 Google Inc. |
7 | | # Copyright 2025 Azhar Momin <azhar.momin@kdemail.net> |
8 | | # |
9 | | # Licensed under the Apache License, Version 2.0 (the "License"); |
10 | | # you may not use this file except in compliance with the License. |
11 | | # You may obtain a copy of the License at |
12 | | # |
13 | | # http://www.apache.org/licenses/LICENSE-2.0 |
14 | | # |
15 | | # Unless required by applicable law or agreed to in writing, software |
16 | | # distributed under the License is distributed on an "AS IS" BASIS, |
17 | | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
18 | | # See the License for the specific language governing permissions and |
19 | | # limitations under the License. |
20 | | # |
21 | | ################################################################################ |
22 | | */ |
23 | | |
24 | | /* |
25 | | Usage: |
26 | | python infra/helper.py build_image karchive |
27 | | python infra/helper.py build_fuzzers --sanitizer undefined|address|memory karchive |
28 | | python infra/helper.py run_fuzzer karchive k[ar|tar|zip|7z]_fuzzer |
29 | | */ |
30 | | |
31 | | #include <QBuffer> |
32 | | #include <QCoreApplication> |
33 | | |
34 | | #include <k7zip.h> |
35 | | #include <kar.h> |
36 | | #include <ktar.h> |
37 | | #include <kzip.h> |
38 | | |
39 | | #include "karchive_fuzzer_common.h" |
40 | | |
41 | | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
42 | 32.6k | { |
43 | 32.6k | int argc = 0; |
44 | 32.6k | QCoreApplication a(argc, nullptr); |
45 | | |
46 | 32.6k | QBuffer b; |
47 | 32.6k | b.setData((const char *)data, size); |
48 | | |
49 | 32.6k | #ifdef HANDLER |
50 | 32.6k | HANDLER handler(&b); |
51 | | |
52 | | #ifdef USE_PASSWORD |
53 | | handler.setPassword("youshallnotpass"); |
54 | | #endif |
55 | | |
56 | 32.6k | if (handler.open(QIODevice::ReadOnly)) { |
57 | 23.5k | traverseArchive(handler.directory()); |
58 | 23.5k | handler.close(); |
59 | 23.5k | } |
60 | 32.6k | #endif |
61 | | |
62 | 32.6k | return 0; |
63 | 32.6k | } |