aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-02-10 15:50:28 -0500
committerNick Mathewson <nickm@torproject.org>2016-02-10 15:50:28 -0500
commit162d2022e1fa4d46480727bae9db650d50c4a21c (patch)
tree21faf984eabfe82d126d5def1e432d6e6fafb4c8 /src
parent44ea7af6860a069435b264f5fe5eea0123ab7d97 (diff)
parent601b41084af1f941c4266237e2c6df46be8981dd (diff)
downloadtor-162d2022e1fa4d46480727bae9db650d50c4a21c.tar.gz
tor-162d2022e1fa4d46480727bae9db650d50c4a21c.zip
Merge branch 'bug17682_squashed'
Diffstat (limited to 'src')
-rw-r--r--src/or/main.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/or/main.c b/src/or/main.c
index e40607036e..591d4b2366 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1376,11 +1376,23 @@ reschedule_directory_downloads(void)
periodic_event_reschedule(launch_descriptor_fetches_event);
}
+#define LONGEST_TIMER_PERIOD (30 * 86400)
+/** Helper: Return the number of seconds between <b>now</b> and <b>next</b>,
+ * clipped to the range [1 second, LONGEST_TIMER_PERIOD]. */
static inline int
safe_timer_diff(time_t now, time_t next)
{
if (next > now) {
- tor_assert(next - now <= INT_MAX);
+ /* There were no computers at signed TIME_MIN (1902 on 32-bit systems),
+ * and nothing that could run Tor. It's a bug if 'next' is around then.
+ * On 64-bit systems with signed TIME_MIN, TIME_MIN is before the Big
+ * Bang. We cannot extrapolate past a singularity, but there was probably
+ * nothing that could run Tor then, either.
+ **/
+ tor_assert(next > TIME_MIN + LONGEST_TIMER_PERIOD);
+
+ if (next - LONGEST_TIMER_PERIOD > now)
+ return LONGEST_TIMER_PERIOD;
return (int)(next - now);
} else {
return 1;