aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2014-04-02 11:50:11 +0200
committerTobias Brunner <tobias@strongswan.org>2014-04-02 11:50:11 +0200
commitf678bce84c2beace8b89ea5ffa9537271a7125fb (patch)
tree1c3f49ea6f67960a07f7aca7d8552e5e96c85c54
parentb87f7840bc090de5b76328c4c12dfb7e27e73f7e (diff)
downloadstrongswan-f678bce84c2beace8b89ea5ffa9537271a7125fb.tar.bz2
strongswan-f678bce84c2beace8b89ea5ffa9537271a7125fb.tar.xz
unit-tests: Verify two bytes at once when testing chunk_clear()
This reduces the chances of arbitrary test failures if the memory area already got overwritten.
-rw-r--r--src/libstrongswan/tests/suites/test_chunk.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstrongswan/tests/suites/test_chunk.c b/src/libstrongswan/tests/suites/test_chunk.c
index e373fbdb6..34ace2894 100644
--- a/src/libstrongswan/tests/suites/test_chunk.c
+++ b/src/libstrongswan/tests/suites/test_chunk.c
@@ -117,10 +117,13 @@ START_TEST(test_chunk_clear)
}
chunk_clear(&chunk);
/* check memory area of freed chunk. We can't use ck_assert() for this
- * test directly, as it might allocate data at the freed area. */
- for (i = 0; i < 64; i++)
+ * test directly, as it might allocate data at the freed area. comparing
+ * two bytes at once reduces the chances of conflicts if memory got
+ * overwritten already */
+ for (i = 0; i < 64; i += 2)
{
- if (ptr[i] != 0 && ptr[i] == i)
+ if (ptr[i] != 0 && ptr[i] == i &&
+ ptr[i+1] != 0 && ptr[i+1] == i+1)
{
cleared = FALSE;
break;