| 1 | // __ _____ _____ _____ |
| 2 | // __| | __| | | | JSON for Modern C++ (supporting code) |
| 3 | // | | |__ | | | | | | version 3.12.0 |
| 4 | // |_____|_____|_____|_|___| https://github.com/nlohmann/json |
| 5 | // |
| 6 | // SPDX-FileCopyrightText: 2013 - 2025 Niels Lohmann <https://nlohmann.me> |
| 7 | // SPDX-License-Identifier: MIT |
| 8 | |
| 9 | /* |
| 10 | This file implements a driver for American Fuzzy Lop (afl-fuzz). It relies on |
| 11 | an implementation of the `LLVMFuzzerTestOneInput` function which processes a |
| 12 | passed byte array. |
| 13 | */ |
| 14 | |
| 15 | #include <vector> // for vector |
| 16 | #include <cstdint> // for uint8_t |
| 17 | #include <iostream> // for cin |
| 18 | |
| 19 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); |
| 20 | |
| 21 | int main() |
| 22 | { |
| 23 | #ifdef __AFL_HAVE_MANUAL_CONTROL |
| 24 | while (__AFL_LOOP(1000)) |
| 25 | { |
| 26 | #endif |
| 27 | // copy stdin to byte vector |
| 28 | std::vector<uint8_t> vec; |
| 29 | char c = 0; |
| 30 | while (std::cin.get(c)) |
| 31 | { |
| 32 | vec.push_back(static_cast<uint8_t>(c)); |
| 33 | } |
| 34 | |
| 35 | LLVMFuzzerTestOneInput(vec.data(), vec.size()); |
| 36 | #ifdef __AFL_HAVE_MANUAL_CONTROL |
| 37 | } |
| 38 | #endif |
| 39 | } |