summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-06 19:50:08 -0500
committerNick Mathewson <nickm@torproject.org>2016-11-06 19:50:08 -0500
commit1b22eae120ff379f7218b4e8b4fb62ed2bfede73 (patch)
treef46eefbbbc3fcf0085be23462db43a622b1b4888
parentadd164aa41724ba6d66c961f37bd798e268062d2 (diff)
downloadtor-1b22eae120ff379f7218b4e8b4fb62ed2bfede73.tar.gz
tor-1b22eae120ff379f7218b4e8b4fb62ed2bfede73.zip
Fix get_delay() code to avoid TIME_MAX overflow, not INT_MAX.
Fixes bug 20587; bugfix on 35bbf2e4a4e8ccb in 0.2.8.1-alpha.
-rw-r--r--changes/bug205876
-rw-r--r--src/or/directory.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/changes/bug20587 b/changes/bug20587
new file mode 100644
index 0000000000..a05933427c
--- /dev/null
+++ b/changes/bug20587
@@ -0,0 +1,6 @@
+
+ o Minor bugfixes (download timing):
+ - When determining when to download a directory object, handle times
+ after 2038 if the operating system supports that. (Someday this will be
+ important!) Fixes bug 20587; bugfix on 0.2.8.1-alpha.
+
diff --git a/src/or/directory.c b/src/or/directory.c
index 1f894d9fb3..afe5796afb 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3876,9 +3876,9 @@ download_status_schedule_get_delay(download_status_t *dls,
* non-negative allows us to safely do the wrapping check below. */
tor_assert(delay >= 0);
- /* Avoid now+delay overflowing INT_MAX, by comparing with a subtraction
+ /* Avoid now+delay overflowing TIME_MAX, by comparing with a subtraction
* that won't overflow (since delay is non-negative). */
- if (delay < INT_MAX && now <= INT_MAX - delay) {
+ if (delay < INT_MAX && now <= TIME_MAX - delay) {
dls->next_attempt_at = now+delay;
} else {
dls->next_attempt_at = TIME_MAX;