]> granicus.if.org Git - pdns/commitdiff
Use dns_random() for generating the id of the notify message.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 14 Feb 2019 15:10:00 +0000 (16:10 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 14 Feb 2019 15:10:00 +0000 (16:10 +0100)
This does introduce a (conditional) dependency on libsodium.

pdns/Makefile.am
pdns/notify.cc

index 40030a515e85c4296c0dc84e69c388932b14c848..f0acec88a65dbee2ce2c997a8a40ca33a246772f 100644 (file)
@@ -1058,7 +1058,8 @@ pdns_notify_SOURCES = \
        rcpgenerator.cc rcpgenerator.hh \
        sillyrecords.cc \
        statbag.cc \
-       unix_utility.cc
+       unix_utility.cc \
+       dns_random.cc
 
 pdns_notify_LDFLAGS = \
        $(AM_LDFLAGS) \
@@ -1069,6 +1070,10 @@ pdns_notify_LDADD = \
        $(LIBCRYPTO_LIBS) \
        $(BOOST_PROGRAM_OPTIONS_LIBS)
 
+if LIBSODIUM
+pdns_notify_LDADD += $(LIBSODIUM_LIBS)
+endif
+
 dnsscope_SOURCES = \
        arguments.cc \
        base32.cc \
index 92cb57ae7bc7b4623570a4e10dcd82513f53360e..2dc595bf0cbf2818cb74f3298acab42e2aed3231 100644 (file)
@@ -24,6 +24,7 @@
 #endif
 #include <bitset>
 #include "dnsparser.hh"
+#include "dns_random.hh"
 #include "iputils.hh"
 #include <boost/program_options.hpp>
 
@@ -112,7 +113,7 @@ try
     }
     vector<uint8_t> outpacket;
     DNSPacketWriter pw(outpacket, DNSName(argv[2]), QType::SOA, 1, Opcode::Notify);
-    pw.getHeader()->id = random();
+    pw.getHeader()->id = dns_random(UINT16_MAX);
 
     if(send(sock, &outpacket[0], outpacket.size(), 0) < 0) {
       cerr<<"Unable to send notify to "<<addr.toStringWithPort()<<": "+stringerror()<<endl;