Skip to content
Snippets Groups Projects
Commit c9e3f502 authored by Vort's avatar Vort
Browse files

Prevent monotime overflow

parent 6d6bd21b
No related branches found
No related tags found
No related merge requests found
......@@ -73,6 +73,7 @@ tor_sleep_msec(int msec)
}
#endif /* defined(TOR_UNIT_TESTS) */
#define TEN_THOUSAND ((int64_t) (10 * 1000))
#define ONE_MILLION ((int64_t) (1000 * 1000))
#define ONE_BILLION ((int64_t) (1000 * 1000 * 1000))
......@@ -522,6 +523,12 @@ monotime_init_internal(void)
tor_assert(n <= INT64_MAX);
tor_assert(d <= INT64_MAX);
while (d > TEN_THOUSAND) {
n /= 10;
d /= 10;
}
simplify_fraction64(&n, &d);
nsec_per_tick_numer = (int64_t) n;
nsec_per_tick_denom = (int64_t) d;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment