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