]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
crypto: Clarifying comment for the random hostname calculation
authorDavid Goulet <dgoulet@torproject.org>
Tue, 15 Mar 2022 18:00:00 +0000 (14:00 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 15 Mar 2022 18:00:00 +0000 (14:00 -0400)
Closes #40520

Signed-off-by: David Goulet <dgoulet@torproject.org>
src/lib/crypt_ops/crypto_rand.c

index 5bf3a65b3bfe1bb03397335a21c45cd0f221a7e5..f39ee6c24f093955f6c3e6f93608d1098ac3dc14 100644 (file)
@@ -568,6 +568,8 @@ crypto_random_hostname(int min_rand_len, int max_rand_len, const char *prefix,
   prefixlen = strlen(prefix);
   resultlen = prefixlen + strlen(suffix) + randlen + 16;
 
+  /* (x+(n-1))/n is an idiom for dividing x by n, rounding up to the nearest
+   * integer and thus why this construction. */
   rand_bytes_len = ((randlen*5)+7)/8;
   if (rand_bytes_len % 5)
     rand_bytes_len += 5 - (rand_bytes_len%5);