Fix remaining non-determinism in fuzzer transcripts.
Both the C and Go code were sampling the real clock. With this, two
successive iterations of runner transcripts give the same output.
Change-Id: I4d9e219e863881bf518c5ac199dce938a49cdfaa
Reviewed-on: https://boringssl-review.googlesource.com/11222
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 6ec7d25..a51688d 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -3013,7 +3013,10 @@
return;
}
-#if defined(OPENSSL_WINDOWS)
+#if defined(BORINGSSL_UNSAFE_FUZZER_MODE)
+ out_clock->tv_sec = 1234;
+ out_clock->tv_usec = 1234;
+#elif defined(OPENSSL_WINDOWS)
struct _timeb time;
_ftime(&time);
out_clock->tv_sec = time.time;
diff --git a/ssl/ssl_session.c b/ssl/ssl_session.c
index 78dfeab..1e7f432 100644
--- a/ssl/ssl_session.c
+++ b/ssl/ssl_session.c
@@ -234,6 +234,9 @@
memcpy(new_session->peer_sha256, session->peer_sha256, SHA256_DIGEST_LENGTH);
new_session->peer_sha256_valid = session->peer_sha256_valid;
+ new_session->timeout = session->timeout;
+ new_session->time = session->time;
+
/* Copy non-authentication connection properties. */
if (dup_flags & SSL_SESSION_INCLUDE_NONAUTH) {
new_session->session_id_length = session->session_id_length;
@@ -241,8 +244,6 @@
session->session_id_length);
new_session->key_exchange_info = session->key_exchange_info;
- new_session->timeout = session->timeout;
- new_session->time = session->time;
if (session->tlsext_hostname != NULL) {
new_session->tlsext_hostname = BUF_strdup(session->tlsext_hostname);
diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go
index ba337d2..162b15e 100644
--- a/ssl/test/runner/runner.go
+++ b/ssl/test/runner/runner.go
@@ -442,6 +442,9 @@
if *fuzzer {
config.Bugs.NullAllCiphers = true
}
+ if *deterministic {
+ config.Time = func() time.Time { return time.Unix(1234, 1234) }
+ }
conn = &timeoutConn{conn, *idleTimeout}