Skip to content

Commit

Permalink
Convert a couple of calls from dns_random() to dns_random_uint32()
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Jun 19, 2023
1 parent 5ca89a0 commit e556776
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pdns/lua-base4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ void BaseLua4::prepareContext() {
SLOG(g_log << (Logger::Urgency)loglevel.get_value_or(Logger::Warning) << msg<<endl,
g_slog->withName("lua")->info(static_cast<Logr::Priority>(loglevel.get_value_or(Logr::Warning)), msg));
});
d_lw->writeFunction("pdnsrandom", [](boost::optional<uint32_t> maximum) { return dns_random(maximum.get_value_or(0xffffffff)); });
d_lw->writeFunction("pdnsrandom", [](boost::optional<uint32_t> maximum) {
return maximum ? dns_random(*maximum) : dns_random_uint32();
});

// certain constants

Expand Down
2 changes: 1 addition & 1 deletion pdns/opensslsigners.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void openssl_seed()

unsigned int r;
for (int i = 0; i < 1024; i += 4) {
r = dns_random(0xffffffff);
r = dns_random_uint32();
entropy.append((const char*)&r, 4);
}

Expand Down
2 changes: 1 addition & 1 deletion pdns/pdnsutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ static void testSpeed(const DNSName& zone, const string& /* remote */, int cores
DTime dt;
dt.set();
for(unsigned int n=0; n < 100000; ++n) {
rnd = dns_random(UINT32_MAX);
rnd = dns_random_uint32();
snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d",
octets[0], octets[1], octets[2], octets[3]);
rr.content=tmp;
Expand Down
2 changes: 1 addition & 1 deletion pdns/recursordist/rec-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ static int serviceMain(Logr::log_t log)

showProductVersion();

g_disthashseed = dns_random(0xffffffff);
g_disthashseed = dns_random_uint32();

int ret = initNet(log);
if (ret != 0) {
Expand Down
2 changes: 1 addition & 1 deletion pdns/tsigutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::string makeTSIGKey(const DNSName& algorithm) {

// Fill out the key
for (size_t i = 0; i < klen; i += sizeof(uint32_t)) {
uint32_t t = dns_random(std::numeric_limits<uint32_t>::max());
uint32_t t = dns_random_uint32();
memcpy(&tmpkey.at(i), &t, sizeof(uint32_t));
}

Expand Down

0 comments on commit e556776

Please sign in to comment.