summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-12-13 10:07:22 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-13 10:09:10 -0500
commitf7e393eb4cd808d349e8dbcc7a547974af086ae2 (patch)
tree20a75e12d76f535a4da64bae0d3bf7005bd23a33
parent15b41fa6ae6a1356d5453242ccb7d7d301dd5e67 (diff)
downloadtor-f7e393eb4cd808d349e8dbcc7a547974af086ae2.tar.gz
tor-f7e393eb4cd808d349e8dbcc7a547974af086ae2.zip
Another attempt at fixing the STACK warning in tortls.c
Patch suggestion from catalyst. Related to 24423
-rw-r--r--src/common/tortls.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 197c5e8d3b..9d2d0240a2 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -491,11 +491,14 @@ tor_tls_create_certificate,(crypto_pk_t *rsa,
* the past. */
const time_t min_real_lifetime = 24*3600;
const time_t start_granularity = 24*3600;
- time_t earliest_start_time = now - cert_lifetime + min_real_lifetime
- + start_granularity;
+ time_t earliest_start_time;
/* Don't actually start in the future! */
- if (earliest_start_time >= now)
+ if (cert_lifetime <= min_real_lifetime + start_granularity) {
earliest_start_time = now - 1;
+ } else {
+ earliest_start_time = now + min_real_lifetime + start_granularity
+ - cert_lifetime;
+ }
start_time = crypto_rand_time_range(earliest_start_time, now);
/* Round the start time back to the start of a day. */
start_time -= start_time % start_granularity;