aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-07-14 03:14:02 +0000
committerRoger Dingledine <arma@torproject.org>2006-07-14 03:14:02 +0000
commitc4411841d23106a59480e2644cb66bf05644273e (patch)
tree7085593f04e4139957c5de2903d750f7cbbbdbe2 /src/or
parent2c20882f0261cadde26c4b200386ecb3c09e5477 (diff)
downloadtor-c4411841d23106a59480e2644cb66bf05644273e.tar
tor-c4411841d23106a59480e2644cb66bf05644273e.tar.gz
Avoid an integer underflow when the dir authority decides whether a
router is stable: we might wrongly label it stable, and compute a slightly wrong median stability, when a descriptor is published later than now. Inspired by Matt's Vidalia checkin: http://trac.vidalia-project.net/changeset/1074 svn:r6758
Diffstat (limited to 'src/or')
-rw-r--r--src/or/dirserv.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 679c169ea..e57ec3ae5 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1227,7 +1227,10 @@ static uint32_t guard_bandwidth = 0;
static INLINE int
real_uptime(routerinfo_t *router, time_t now)
{
- return router->uptime + (now - router->cache_info.published_on);
+ if (now < router->cache_info.published_on)
+ return router->uptime;
+ else
+ return router->uptime + (now - router->cache_info.published_on);
}
/** Return 1 if <b>router</b> is not suitable for these parameters, else 0.