]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Convert a couple of calls from dns_random() to dns_random_uint32() 12913/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 19 Jun 2023 09:33:02 +0000 (11:33 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 19 Jun 2023 09:33:02 +0000 (11:33 +0200)
pdns/lua-base4.cc
pdns/opensslsigners.cc
pdns/pdnsutil.cc
pdns/recursordist/rec-main.cc
pdns/tsigutils.cc

index a0fb5892d3061c91cdcb9295cc6240f5cfd35840..2eae10d9495e1dabdc5d454b4909fec106d74d87 100644 (file)
@@ -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
 
index a8ca7c0712626730620c2f3ebe15e5d975000e80..9b593aa2da7ce762a8f751745ca05afed48c855b 100644 (file)
@@ -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);
   }
 
index 6e0466a9705f78323bebd7f4dc32a6999bdc1ae7..525b4636f43a2e50ccaad1b81b0673707f087169 100644 (file)
@@ -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;
index 1b54fa7fa938e1f3c189734abe011c01e91cfa6b..5199df79c022882ba3ba06fe3e31c548dfe9b928 100644 (file)
@@ -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) {
index 40f49a9119c4216d9262f601f30899d630313825..e81386bd8ff119d97c2dc3339cfb16b4d21d1197 100644 (file)
@@ -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));
   }