From 7b9a420787c71624ff0e9c6bcfe1e72c74feb677 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 3 Jul 2019 11:05:01 +0200 Subject: Replace std::random_shuffle with std::shuffle According to [1], std::random_shuffle is deprecated in C++14 and removed in C++17. Since std::shuffle is available since C++11 as a replacement and monero already requires C++11, this is a good replacement. A cryptographically secure random number generator is used in all cases to prevent people from perhaps copying an insecure std::shuffle call over to a place where a secure one would be warranted. A form of defense-in-depth. [1]: https://en.cppreference.com/w/cpp/algorithm/random_shuffle --- src/p2p/net_peerlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/p2p') diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h index 883997fd6..3041e03b1 100644 --- a/src/p2p/net_peerlist.h +++ b/src/p2p/net_peerlist.h @@ -290,7 +290,7 @@ namespace nodetool if (anonymize) { - std::random_shuffle(bs_head.begin(), bs_head.end()); + std::shuffle(bs_head.begin(), bs_head.end(), crypto::random_device{}); if (bs_head.size() > depth) bs_head.resize(depth); for (auto &e: bs_head) -- cgit v1.2.3