Reject tickets from the future.
This shouldn't happen, but it is good to check to avoid the potential
underflow in ssl_session_is_time_valid.
This required tweaking the mock clock in bssl_shim to stop going back in
time.
Change-Id: Id3ab8755139e989190d0b53d4bf90fe1ac203022
Reviewed-on: https://boringssl-review.googlesource.com/11841
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/ssl/ssl_session.c b/ssl/ssl_session.c
index c2396b1..2c20bc3 100644
--- a/ssl/ssl_session.c
+++ b/ssl/ssl_session.c
@@ -599,6 +599,12 @@
struct timeval now;
ssl_get_current_time(ssl, &now);
+
+ /* Reject tickets from the future to avoid underflow. */
+ if ((long)now.tv_sec < session->time) {
+ return 0;
+ }
+
return session->timeout >= (long)now.tv_sec - session->time;
}