| /* |
| * Copyright (C) 2022 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at: |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| * |
| */ |
| |
| #include <unistd.h> |
| #include <vector> |
| #include "../includes/common.h" |
| #include "../includes/memutils.h" |
| #include "phNxpExtns_MifareStd.h" |
| |
| bool testInProgress = false; |
| char enable_selective_overload = ENABLE_NONE; |
| struct sigaction new_action, old_action; |
| |
| void sigsegv_handler(int signum, siginfo_t *info, void *context) { |
| if (testInProgress && info->si_signo == SIGSEGV) { |
| (*old_action.sa_sigaction)(signum, info, context); |
| return; |
| } |
| _exit(EXIT_FAILURE); |
| } |
| |
| int main() { |
| sigemptyset(&new_action.sa_mask); |
| new_action.sa_flags = SA_SIGINFO; |
| new_action.sa_sigaction = sigsegv_handler; |
| sigaction(SIGSEGV, &new_action, &old_action); |
| constexpr int32_t size = 16; |
| constexpr int32_t index = 1; |
| enable_selective_overload = ENABLE_ALL; |
| std::vector<uint8_t> bufferVector(size); |
| uint8_t *buffer = bufferVector.data(); |
| FAIL_CHECK(buffer); |
| buffer[size - 1] = phNciNfc_e_MfcAuthRsp; |
| phNxpExtns_MfcModuleInit(); |
| testInProgress = true; |
| Mfc_RecvPacket(&buffer[size - 1], index); |
| enable_selective_overload = ENABLE_FREE_CHECK | ENABLE_REALLOC_CHECK; |
| testInProgress = false; |
| return EXIT_SUCCESS; |
| } |