summaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-06-01 12:12:01 -0400
committerNick Mathewson <nickm@torproject.org>2011-06-06 16:18:06 -0400
commit42e4e156d95a1c28a666a5346d491c4ed71435dd (patch)
tree66e8380b129be449e895fa93b7240f80985e7be8 /src/or/circuitbuild.c
parent5afab5ca197112b01135980d6cb3694a4519e3cf (diff)
downloadtor-42e4e156d95a1c28a666a5346d491c4ed71435dd.tar.gz
tor-42e4e156d95a1c28a666a5346d491c4ed71435dd.zip
Detect insanely large circuit build state; don't give its length to rand_int
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 3f08448159..6d7e71194e 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -678,7 +678,15 @@ circuit_build_times_shuffle_and_store_array(circuit_build_times_t *cbt,
log_notice(LD_CIRC, "The number of circuit times that this Tor version "
"uses to calculate build times is less than the number stored "
"in your state file. Decreasing the circuit time history from "
- "%d to %d.", num_times, CBT_NCIRCUITS_TO_OBSERVE);
+ "%lu to %d.", (unsigned long)num_times,
+ CBT_NCIRCUITS_TO_OBSERVE);
+ }
+
+ if (n > INT_MAX-1) {
+ log_warn(LD_CIRC, "For some insane reasons, you had %lu circuit build "
+ "observations in your state file. That's far too many; probably "
+ "there's a bug here.", (unsigned long)n);
+ n = INT_MAX-1;
}
/* This code can only be run on a compact array */