From a2195b9b7fba5da7f47903961db3fb31f6d7146c Mon Sep 17 00:00:00 2001 From: stoffu Date: Wed, 3 Apr 2019 14:10:24 +0900 Subject: crypto: replace rand()%N idiom with unbiased rand_idx(N) --- src/p2p/net_peerlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/p2p/net_peerlist.h') diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h index ebe0268d8..52814af94 100644 --- a/src/p2p/net_peerlist.h +++ b/src/p2p/net_peerlist.h @@ -398,7 +398,7 @@ namespace nodetool return false; } - size_t random_index = crypto::rand() % m_peers_gray.size(); + size_t random_index = crypto::rand_idx(m_peers_gray.size()); peers_indexed::index::type& by_time_index = m_peers_gray.get(); pe = *epee::misc_utils::move_it_backward(--by_time_index.end(), random_index); -- cgit v1.2.3