]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Apply suggestions from code review
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 11 Feb 2025 13:19:55 +0000 (14:19 +0100)
committerGitHub <noreply@github.com>
Tue, 11 Feb 2025 13:19:55 +0000 (14:19 +0100)
Co-authored-by: Remi Gacogne <github@coredump.fr>
docs/manpages/sdig.1.rst
pdns/ednscookies.cc
pdns/sdig.cc

index 996d5ca6ad07f206cc6e5f494fe70be4fea4f82a..25ee18a6c08a9c4e9a86d8dfc8ab3fff56031728 100644 (file)
@@ -58,7 +58,7 @@ tlsProvider *name*
 opcode *OPNUM*
     Use opcode *OPNUM* instead of 0 (Query). For example, ``sdig 192.0.2.1 53 example.com SOA opcode 4`` sends a ``NOTIFY``.
 cookie *COOKIE*
-    if *COOKIE* is -d send a random client cookie. Otherwise send the given cookie, which should be a hex string received from a server earlier.
+    if *COOKIE* is - send a random client cookie. Otherwise send the given cookie, which should be a hex string received from a server earlier.
 
 Examples
 --------
index 253d9bab8ca076552c904a27b55d1296d4b2b48b..c390865ef7a01c0b19cf2fb1cc30306ec644aa2c 100644 (file)
@@ -151,9 +151,9 @@ void EDNSCookiesOpt::makeClientCookie()
   uint32_t lower = dns_random_uint32();
   uint32_t upper = dns_random_uint32();
   client = string();
-  client.resize(8);
+  client.resize(sizeof(lower) + sizeof(upper));
   memcpy(client.data(), &lower, sizeof(lower));
-  memcpy(&client.at(4), &upper, sizeof(upper));
+  memcpy(&client.at(sizeof(lower)), &upper, sizeof(upper));
 }
 
 bool EDNSCookiesOpt::makeServerCookie([[maybe_unused]] const string& secret, [[maybe_unused]] const ComboAddress& source)
index 291b3f1a3889afa91c2f59b6ebc2c082d0df2f9f..065e65e7878a77ae41d64a5190cd929d8ccd3106 100644 (file)
@@ -63,8 +63,8 @@ static void fillPacket(vector<uint8_t>& packet, const string& q, const string& t
 {
   DNSPacketWriter pw(packet, DNSName(q), DNSRecordContent::TypeToNumber(t), qclass, opcode);
 
-  if (dnssec || ednsnm || getenv("SDIGBUFSIZE") != nullptr || cookie) { // NOLINT(concurrency-mt-unsafe) we'resingle threaded
-    char* sbuf = getenv("SDIGBUFSIZE"); // NOLINT(concurrency-mt-unsafe) we'resingle threaded
+  if (dnssec || ednsnm || getenv("SDIGBUFSIZE") != nullptr || cookie) { // NOLINT(concurrency-mt-unsafe) we're single threaded
+    char* sbuf = getenv("SDIGBUFSIZE"); // NOLINT(concurrency-mt-unsafe) we're single threaded
     int bufsize;
     if (sbuf)
       bufsize = atoi(sbuf);
@@ -246,7 +246,7 @@ try {
   bool dumpluaraw = false;
   std::optional<string> cookie;
 
-  // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic, concurrency-mt-unsafe) it's the argv API and w're single-threaded
+  // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic, concurrency-mt-unsafe) it's the argv API and we're single-threaded
   for (int i = 1; i < argc; i++) {
     if ((string)argv[i] == "--help") {
       usage();