1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <ce_int.h>
18 #include <nfc_int.h>
19 
20 #include "../includes/common.h"
21 #include "../includes/memutils.h"
22 
23 #define OFFSET 8
24 #define VULNERABLE_LENGTH 0
25 
26 char enable_selective_overload = ENABLE_NONE;
27 
28 extern tNFC_CB nfc_cb;
29 extern tCE_CB ce_cb;
30 
GKI_freebuf(void * p_buf)31 void GKI_freebuf(void* p_buf __attribute__((unused))) {}
32 
nfc_start_quick_timer(TIMER_LIST_ENT *,uint16_t,uint32_t)33 void nfc_start_quick_timer(TIMER_LIST_ENT*, uint16_t, uint32_t) {}
34 
nfc_stop_timer(TIMER_LIST_ENT *)35 void nfc_stop_timer(TIMER_LIST_ENT*) {}
36 
nfc_stop_quick_timer(TIMER_LIST_ENT *)37 void nfc_stop_quick_timer(TIMER_LIST_ENT*) {}
38 
main()39 int main() {
40     enable_selective_overload = ENABLE_ALL;
41     GKI_init();
42     ce_init();
43     ce_cb.mem.t4t.status = CE_T4T_STATUS_REG_AID_SELECTED;
44 
45     if (ce_select_t4t() != NFC_STATUS_OK) {
46         return EXIT_FAILURE;
47     }
48 
49     tNFC_CONN_CB* p_cb = &nfc_cb.conn_cb[NFC_RF_CONN_ID];
50     tNFC_CONN* p_data = (tNFC_CONN*)malloc(sizeof(tNFC_CONN));
51     p_data->data.p_data = (NFC_HDR*)malloc(sizeof(uint8_t) * 16);
52     NFC_HDR* p_c_apdu = (NFC_HDR*)p_data->data.p_data;
53     p_c_apdu->len = VULNERABLE_LENGTH;
54     p_c_apdu->offset = OFFSET;
55     uint8_t conn_id = 1;
56     TIMER_LIST_ENT pFirst = {};
57     nfc_cb.quick_timer_queue.p_first = &pFirst;
58 
59     p_cb->p_cback(conn_id, NFC_DATA_CEVT, p_data);
60 
61     free(p_data->data.p_data);
62     free(p_data);
63     enable_selective_overload = ENABLE_NONE;
64     return EXIT_SUCCESS;
65 }
66