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
This commit is contained in:
@@ -7448,7 +7448,7 @@ void wallet2::light_wallet_get_outs(std::vector<std::vector<tools::wallet2::get_
|
||||
order.resize(light_wallet_requested_outputs_count);
|
||||
for (size_t n = 0; n < order.size(); ++n)
|
||||
order[n] = n;
|
||||
std::shuffle(order.begin(), order.end(), std::default_random_engine(crypto::rand<unsigned>()));
|
||||
std::shuffle(order.begin(), order.end(), crypto::random_device{});
|
||||
|
||||
|
||||
LOG_PRINT_L2("Looking for " << (fake_outputs_count+1) << " outputs with amounts " << print_money(td.is_rct() ? 0 : td.amount()));
|
||||
@@ -8023,7 +8023,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||
order.resize(requested_outputs_count);
|
||||
for (size_t n = 0; n < order.size(); ++n)
|
||||
order[n] = n;
|
||||
std::shuffle(order.begin(), order.end(), std::default_random_engine(crypto::rand<unsigned>()));
|
||||
std::shuffle(order.begin(), order.end(), crypto::random_device{});
|
||||
|
||||
LOG_PRINT_L2("Looking for " << (fake_outputs_count+1) << " outputs of size " << print_money(td.is_rct() ? 0 : td.amount()));
|
||||
for (size_t o = 0; o < requested_outputs_count && outs.back().size() < fake_outputs_count + 1; ++o)
|
||||
|
||||
Reference in New Issue
Block a user