1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-11-05 08:10:38 +03:00

Change memory poisoning flag to a count

This allows unusually-nested memory poisoning to work correctly, since
it keeps track of whether any buffers are still poisoned, rather than
just disabling poisoning at the first call to the UNPOISON() macro.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann
2024-01-17 14:23:20 +00:00
parent c2ab398d01
commit fad038c501
2 changed files with 5 additions and 5 deletions

View File

@@ -20,7 +20,7 @@
#if defined(MBEDTLS_TEST_MEMORY_CAN_POISON)
_Thread_local int mbedtls_test_memory_poisoning_enabled = 0;
_Thread_local unsigned int mbedtls_test_memory_poisoning_count = 0;
static void align_for_asan(const unsigned char **p_ptr, size_t *p_size)
{
@@ -39,7 +39,7 @@ static void align_for_asan(const unsigned char **p_ptr, size_t *p_size)
void mbedtls_test_memory_poison(const unsigned char *ptr, size_t size)
{
if (!mbedtls_test_memory_poisoning_enabled) {
if (mbedtls_test_memory_poisoning_count == 0) {
return;
}
if (size == 0) {