• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <android-base/logging.h>
2 #include <android-base/stringprintf.h>
3 
4 #include "debug_nfcsnoop.h"
5 #include "fuzzers/integration/nfc_integration_fuzzer.pb.h"
6 #include "gki_common.h"
7 #include "gki_int.h"
8 #include "nfa_ee_api.h"
9 #include "nfc_integration_fuzzer_impl.h"
10 #include "src/libfuzzer/libfuzzer_macro.h"
11 
12 extern bool nfa_poll_bail_out_mode;
13 
DEFINE_BINARY_PROTO_FUZZER(const Session & session)14 DEFINE_BINARY_PROTO_FUZZER(const Session& session) {
15   static bool init = false;
16   if (!init) {
17     nfa_poll_bail_out_mode = true;
18     // 0x90 is the protocol value on Pixel 4a. The default value (0xFF)
19     // will prevent Mifare from being discoverable.
20     p_nfa_proprietary_cfg->pro_protocol_mfc = 0x90;
21     debug_nfcsnoop_init();
22     gki_buffer_init();
23     gki_cb.com.OSRdyTbl[BTU_TASK] = TASK_READY;
24     gki_cb.com.OSRdyTbl[MMI_TASK] = TASK_READY;
25     gki_cb.com.OSRdyTbl[NFC_TASK] = TASK_READY;
26     init = true;
27   }
28 
29   // Print the testcase in debug mode
30   if (android::base::GetMinimumLogSeverity() <= android::base::DEBUG) {
31     std::string str;
32     google::protobuf::TextFormat::PrintToString(session, &str);
33     LOG(INFO) << str;
34   }
35 
36   NfcIntegrationFuzzer nfc_integration_fuzzer(&session);
37   if (!nfc_integration_fuzzer.Setup()) {
38     return;
39   }
40 
41   nfc_integration_fuzzer.RunCommands();
42 }
43