[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Backport: Avoid an integer underflow when the dir authority...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/tor-011x/tor/src/or

Modified Files:
      Tag: tor-0_1_1-patches
	dirserv.c 
Log Message:
Backport: Avoid an integer underflow when the dir authority decides
whether a router is stable.


Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.328
retrieving revision 1.328.2.1
diff -u -p -d -r1.328 -r1.328.2.1
--- dirserv.c	10 Apr 2006 01:35:56 -0000	1.328
+++ dirserv.c	14 Jul 2006 03:17:49 -0000	1.328.2.1
@@ -1193,7 +1193,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.