summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorMike Bland <mbland@acm.org>2014-05-01 16:10:14 +0200
committerBen Laurie <ben@links.org>2014-05-19 18:39:41 +0200
commit39dd6f4549cf4474f6f6eb4cf9983380215a1c21 (patch)
treed1a9c203583067d11c992598a893d85241c4c55c /ssl
parentMore through error checks in set_up (diff)
downloadopenssl-39dd6f4549cf4474f6f6eb4cf9983380215a1c21.tar.xz
openssl-39dd6f4549cf4474f6f6eb4cf9983380215a1c21.zip
Zero-initialize heartbeat test write buffer
The previous calls to memset() were added to tear_down() when I noticed the test spuriously failing in opt mode, with different results each time. This appeared to be because the allocator zeros out memory in debug mode, but not in opt mode. Since the heartbeat functions silently drop the request on error without modifying the contents of the write buffer, whatever random contents were in memory before being reallocated to the write buffer used in the test would cause nondeterministic test failures in the Heartbleed regression cases. Adding these calls allowed the test to pass in both debug and opt modes. Ben Laurie notified me offline that the test was aborting in debug-ben-debug-64-clang mode, configured with GitConfigure and built with GitMake. Looking into this, I realized the first memset() call was zeroing out a reference count used by SSL_free() that was checked in debug-ben-debug-64-clang mode but not in the normal debug mode. Removing the memset() calls from tear_down() and adding a memset() for the write buffer in set_up() addresses the issue and allows the test to successfully execute in debug, opt, and debug-ben-debug-64-clang modes.
Diffstat (limited to 'ssl')
-rw-r--r--ssl/heartbeat_test.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ssl/heartbeat_test.c b/ssl/heartbeat_test.c
index 23ae0532d5..f86ec5f152 100644
--- a/ssl/heartbeat_test.c
+++ b/ssl/heartbeat_test.c
@@ -105,6 +105,12 @@ static HEARTBEAT_TEST_FIXTURE set_up(const char* const test_case_name,
goto fail;
}
+ /* Clear the memory for the return buffer, since this isn't automatically
+ * zeroed in opt mode and will cause spurious test failures that will change
+ * with each execution.
+ */
+ memset(fixture.s->s3->wbuf.buf, 0, fixture.s->s3->wbuf.len);
+
fail:
if (!setup_ok)
{
@@ -160,9 +166,7 @@ static HEARTBEAT_TEST_FIXTURE set_up_tls(const char* const test_case_name)
static void tear_down(HEARTBEAT_TEST_FIXTURE fixture)
{
ERR_print_errors_fp(stderr);
- memset(fixture.s, 0, sizeof(*fixture.s));
SSL_free(fixture.s);
- memset(fixture.ctx, 0, sizeof(*fixture.ctx));
SSL_CTX_free(fixture.ctx);
}