xref: /aosp_15_r20/system/nfc/src/fuzzers/fuzz_cmn.cc (revision 7eba2f3b06c51ae21384f6a4f14577b668a869b3)
1 #include "fuzz_cmn.h"
2 
nfcsnoop_capture(NFC_HDR const *,bool)3 void nfcsnoop_capture(NFC_HDR const*, bool){};
delete_stack_non_volatile_store(bool)4 void delete_stack_non_volatile_store(bool){};
debug_nfcsnoop_dump(int)5 void debug_nfcsnoop_dump(int){};
6 std::string nfc_storage_path;
storeNfcSnoopLogs(std::string,off_t)7 bool storeNfcSnoopLogs(std::string, off_t) { return true; };
8 
9 uint8_t appl_dta_mode_flag = 0;
10 unsigned int t5t_mute_legacy = 0;
11 bool nfc_nci_reset_keep_cfg_enabled = false;
12 uint8_t nfc_nci_reset_type = 0x00;
13 
14 namespace android {
15 namespace util {
stats_write(int32_t,...)16 void stats_write(int32_t, ...) {}
17 }  // namespace util
18 }  // namespace android
19 
20 #ifdef STANDALONE_FUZZER
main(int argc,char * argv[])21 int main(int argc, char* argv[]) {
22   uint_t iterations = 50;
23   uint_t seed = 0;
24 
25   if (argc >= 2) {
26     seed = atol(argv[1]);
27   }
28 
29   if (argc >= 3) {
30     iterations = atol(argv[2]);
31   }
32 
33   FUZZLOG("iterations=%d, seed=%d", iterations, seed);
34 
35   if (0 != LLVMFuzzerInitialize(&argc, &argv)) {
36     return -1;
37   }
38 
39   for (auto i = 0; i < iterations; i++) {
40     FUZZLOG("iteration=%d, seed=%d", i, seed);
41     srandom(seed);
42     seed = random();
43     auto data = FuzzSeqGen(3, 255);
44     if (!LLVMFuzzerTestOneInput(&data[0], data.size())) {
45       break;
46     }
47   }
48 
49   return 0;
50 }
51 #endif
52