summaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2015-04-21 10:17:12 -0400
committerDavid Goulet <dgoulet@ev0ke.net>2015-04-21 11:06:12 -0400
commit3f413184728c1d7b441b8e54585c43220665218c (patch)
tree4098cf1f1c596e98a3be1a5c78f3d07aa3d353e8 /src/or/rendservice.c
parent6f6881c4324f35d44b997591939de7e847cca7a3 (diff)
downloadtor-3f413184728c1d7b441b8e54585c43220665218c.tar.gz
tor-3f413184728c1d7b441b8e54585c43220665218c.zip
Add crypto_rand_int_range() and use it
Incidently, this fixes a bug where the maximum value was never used when only using crypto_rand_int(). For instance this example below in rendservice.c never gets to INTRO_POINT_LIFETIME_MAX_SECONDS. int intro_point_lifetime_seconds = INTRO_POINT_LIFETIME_MIN_SECONDS + crypto_rand_int(INTRO_POINT_LIFETIME_MAX_SECONDS - INTRO_POINT_LIFETIME_MIN_SECONDS); Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index cf0352cd3e..4b2331ffca 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -3133,9 +3133,8 @@ intro_point_should_expire_now(rend_intro_point_t *intro,
/* This intro point has been published, but we haven't picked an
* expiration time for it. Pick one now. */
int intro_point_lifetime_seconds =
- INTRO_POINT_LIFETIME_MIN_SECONDS +
- crypto_rand_int(INTRO_POINT_LIFETIME_MAX_SECONDS -
- INTRO_POINT_LIFETIME_MIN_SECONDS);
+ crypto_rand_int_range(INTRO_POINT_LIFETIME_MIN_SECONDS,
+ INTRO_POINT_LIFETIME_MAX_SECONDS);
/* Start the expiration timer now, rather than when the intro
* point was first published. There shouldn't be much of a time
@@ -3337,9 +3336,8 @@ rend_services_introduce(void)
intro->time_to_expire = -1;
intro->time_expiring = -1;
intro->max_introductions =
- INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS +
- crypto_rand_int(INTRO_POINT_MAX_LIFETIME_INTRODUCTIONS -
- INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS);
+ crypto_rand_int_range(INTRO_POINT_MIN_LIFETIME_INTRODUCTIONS,
+ INTRO_POINT_MAX_LIFETIME_INTRODUCTIONS);
smartlist_add(service->intro_nodes, intro);
log_info(LD_REND, "Picked router %s as an intro point for %s.",
safe_str_client(node_describe(node)),