diff options
author | Riccardo Spagni <ric@spagni.net> | 2019-04-15 09:14:28 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2019-04-15 09:14:28 +0200 |
commit | 89b8ecfc7c88510681b6d354586e68510c150cda (patch) | |
tree | bd3ae35111a04d726f85fa2f9e2e36da0f23a51a /src/common | |
parent | Merge pull request #5369 (diff) | |
parent | crypto: replace rand<T>()%N idiom with unbiased rand_idx(N) (diff) | |
download | monero-89b8ecfc7c88510681b6d354586e68510c150cda.tar.xz |
Merge pull request #5392
a2195b9b crypto: replace rand<T>()%N idiom with unbiased rand_idx(N) (stoffu)
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/dns_utils.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/common/dns_utils.cpp b/src/common/dns_utils.cpp index 1a1155c7c..5e03bf897 100644 --- a/src/common/dns_utils.cpp +++ b/src/common/dns_utils.cpp @@ -33,7 +33,7 @@ #include <stdlib.h> #include "include_base_utils.h" #include "common/threadpool.h" -#include <random> +#include "crypto/crypto.h" #include <boost/thread/mutex.hpp> #include <boost/algorithm/string/join.hpp> #include <boost/optional.hpp> @@ -517,10 +517,7 @@ bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std std::vector<std::vector<std::string> > records; records.resize(dns_urls.size()); - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<int> dis(0, dns_urls.size() - 1); - size_t first_index = dis(gen); + size_t first_index = crypto::rand_idx(dns_urls.size()); // send all requests in parallel std::deque<bool> avail(dns_urls.size(), false), valid(dns_urls.size(), false); |