From 026e7987ad312a26efb926ae44adc158770de7cd Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Thu, 30 Dec 2010 19:54:13 +0100 Subject: Sanity-check consensus param values We need to make sure that the worst thing that a weird consensus param can do to us is to break our Tor (and only if the other Tors are reliably broken in the same way) so that the majority of directory authorities can't pull any attacks that are worse than the DoS that they can trigger by simply shutting down. One of these worse things was the cbtnummodes parameter, which could lead to heap corruption on some systems if the value was sufficiently large. This commit fixes this particular issue and also introduces sanity checking for all consensus parameters. --- src/test/test_dir.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/test_dir.c b/src/test/test_dir.c index e61815027c..1f3beb4baa 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -609,8 +609,11 @@ test_dir_param_voting(void) "abcd=20 c=60 cw=500 x-yz=-9 zzzzz=101", NULL, 0, 0); smartlist_split_string(vote4.net_params, "ab=900 abcd=200 c=1 cw=51 x-yz=100", NULL, 0, 0); - test_eq(100, networkstatus_get_param(&vote4, "x-yz", 50)); - test_eq(222, networkstatus_get_param(&vote4, "foobar", 222)); + test_eq(100, networkstatus_get_param(&vote4, "x-yz", 50, 0, 300)); + test_eq(222, networkstatus_get_param(&vote4, "foobar", 222, 0, 300)); + test_eq(80, networkstatus_get_param(&vote4, "ab", 12, 0, 80)); + test_eq(-8, networkstatus_get_param(&vote4, "ab", -12, -100, -8)); + test_eq(0, networkstatus_get_param(&vote4, "foobar", 0, -100, 8)); smartlist_add(votes, &vote1); smartlist_add(votes, &vote2); -- cgit v1.2.3-54-g00ecf