Gilles Peskine | 87270e5 | 2023-11-02 17:14:01 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file memory.c |
| 3 | * |
| 4 | * \brief Helper functions related to testing memory management. |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Copyright The Mbed TLS Contributors |
| 9 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
| 10 | */ |
| 11 | |
| 12 | #include <test/helpers.h> |
| 13 | #include <test/macros.h> |
| 14 | #include <test/memory.h> |
| 15 | |
Gilles Peskine | 071d144 | 2023-11-02 20:49:34 +0100 | [diff] [blame^] | 16 | #if defined(MBEDTLS_TEST_HAVE_ASAN) |
| 17 | #include <sanitizer/asan_interface.h> |
| 18 | #include <stdint.h> |
| 19 | #endif |
| 20 | |
| 21 | #if defined(MBEDTLS_TEST_HAVE_ASAN) |
| 22 | void mbedtls_test_memory_poison(const unsigned char *ptr, size_t size) |
| 23 | { |
| 24 | if (size == 0) { |
| 25 | return; |
| 26 | } |
| 27 | __asan_poison_memory_region(ptr, size); |
| 28 | } |
| 29 | |
| 30 | void mbedtls_test_memory_unpoison(const unsigned char *ptr, size_t size) |
| 31 | { |
| 32 | if (size == 0) { |
| 33 | return; |
| 34 | } |
| 35 | __asan_unpoison_memory_region(ptr, size); |
| 36 | } |
| 37 | #endif /* Asan */ |