]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a 30-day maximum on user-supplied MaxCircuitDirtiness
authorNick Mathewson <nickm@torproject.org>
Wed, 21 Aug 2013 15:35:00 +0000 (11:35 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 21 Aug 2013 15:35:00 +0000 (11:35 -0400)
Fix for bug 9543.

changes/bug9543 [new file with mode: 0644]
src/or/config.c

diff --git a/changes/bug9543 b/changes/bug9543
new file mode 100644 (file)
index 0000000..753947f
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Avoid overflows when the user sets MaxCircuitDirtiness to a
+      ridiculously high value, by imposing a (ridiculously high) 30-day
+      maximum on MaxCircuitDirtiness.
index 72ceea395ed1757a62c5b7780c981697a42074da..793fd557a36a84a0a3b3ee2e478380b0883b70c4 100644 (file)
@@ -2266,6 +2266,10 @@ compute_publishserverdescriptor(or_options_t *options)
  * will generate too many circuits and potentially overload the network. */
 #define MIN_MAX_CIRCUIT_DIRTINESS 10
 
+/** Highest allowable value for MaxCircuitDirtiness: prevents time_t
+ * overflows. */
+#define MAX_MAX_CIRCUIT_DIRTINESS (30*24*60*60)
+
 /** Lowest allowable value for CircuitStreamTimeout; if this is too low, Tor
  * will generate too many circuits and potentially overload the network. */
 #define MIN_CIRCUIT_STREAM_TIMEOUT 10
@@ -2786,6 +2790,12 @@ options_validate(or_options_t *old_options, or_options_t *options,
     options->MaxCircuitDirtiness = MIN_MAX_CIRCUIT_DIRTINESS;
   }
 
+  if (options->MaxCircuitDirtiness > MAX_MAX_CIRCUIT_DIRTINESS) {
+    log_warn(LD_CONFIG, "MaxCircuitDirtiness option is too high; "
+             "setting to %d days.", MAX_MAX_CIRCUIT_DIRTINESS/86400);
+    options->MaxCircuitDirtiness = MAX_MAX_CIRCUIT_DIRTINESS;
+  }
+
   if (options->CircuitStreamTimeout &&
       options->CircuitStreamTimeout < MIN_CIRCUIT_STREAM_TIMEOUT) {
     log_warn(LD_CONFIG, "CircuitStreamTimeout option is too short; "