1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2 // See https://llvm.org/LICENSE.txt for license information. 3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 5 // Parse some flags 6 #include <string> 7 #include <vector> 8 9 static std::vector<std::string> Flags; 10 11 extern "C" int LLVMFuzzerInitialize(int *Argc, char ***Argv) { 12 // Parse --flags and anything after -ignore_remaining_args=1 is passed. 13 int I = 1; 14 while (I < *Argc) { 15 std::string S((*Argv)[I++]); 16 if (S == "-ignore_remaining_args=1") 17 break; 18 if (S.substr(0, 2) == "--") 19 Flags.push_back(S); 20 } 21 while (I < *Argc) 22 Flags.push_back(std::string((*Argv)[I++])); 23 24 return 0; 25 } 26 27 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 28 fprintf(stderr, "BINGO "); 29 for (auto Flag : Flags) 30 fprintf(stderr, "%s ", Flag.c_str()); 31 fprintf(stderr, "\n"); 32 return 0; 33 } 34