bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/6] Fix test in case of canaries on heap buffer after free


From: roucaries . bastien
Subject: [PATCH 1/6] Fix test in case of canaries on heap buffer after free
Date: Mon, 13 Apr 2020 01:09:13 +0200

From: Bastien Roucariès <address@hidden>

Some implementation could add canaries after free failling the test

Signed-off-by: Bastien Roucariès <address@hidden>
---
 tests/test-explicit_bzero.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/test-explicit_bzero.c b/tests/test-explicit_bzero.c
index 526ccfd48..54eb08b26 100644
--- a/tests/test-explicit_bzero.c
+++ b/tests/test-explicit_bzero.c
@@ -112,7 +112,9 @@ test_heap (void)
   free (heapbuf);
   if (is_range_mapped (addr, addr + SECRET_SIZE))
     {
-      ASSERT (memcmp (zero, heapbuf, SECRET_SIZE) == 0);
+      /* some implementation could override freed memory by canaries so
+         compare against secret */
+      ASSERT (memcmp (SECRET, heapbuf, SECRET_SIZE) != 0);
       printf ("test_heap: address range is still mapped after free().\n");
     }
   else
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]