]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #12739 from omoerbeek/rec-lwres-uninited-len
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 3 May 2023 12:50:18 +0000 (14:50 +0200)
committerGitHub <noreply@github.com>
Wed, 3 May 2023 12:50:18 +0000 (14:50 +0200)
rec: Fix uninited var causing wrong `bytes` field reported in protobuf log in rare cases

pdns/recursordist/lwres.cc
pdns/recursordist/lwres.hh
pdns/recursordist/pdns_recursor.cc

index 833ae7ffc1486db10ddb2c6694115fcd8cda85bc..ad9bcbb81d5cdd4c72fbbcf8502ca9a708c3aa56 100644 (file)
@@ -495,7 +495,7 @@ static LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& doma
 #endif /* HAVE_FSTRM */
 
     // sleep until we see an answer to this, interface to mtasker
-    ret = arecvfrom(buf, 0, ip, &len, qid, domain, type, queryfd, now);
+    ret = arecvfrom(buf, 0, ip, len, qid, domain, type, queryfd, *now);
   }
   else {
     bool isNew;
index 1f4e22eb41d2f9121d2a0bf3b0babe5b86fc1fc7..52ed30ec1ad57f1e7d492903813765b1f6d4d188 100644 (file)
@@ -85,7 +85,7 @@ public:
 
 LWResult::Result asendto(const char* data, size_t len, int flags, const ComboAddress& ip, uint16_t id,
                          const DNSName& domain, uint16_t qtype, bool ecs, int* fd);
-LWResult::Result arecvfrom(PacketBuffer& packet, int flags, const ComboAddress& ip, size_t* d_len, uint16_t id,
-                           const DNSName& domain, uint16_t qtype, int fd, const struct timeval* now);
+LWResult::Result arecvfrom(PacketBuffer& packet, int flags, const ComboAddress& ip, size_tlen, uint16_t id,
+                           const DNSName& domain, uint16_t qtype, int fd, const struct timeval& now);
 
 LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional<Netmask>& srcmask, boost::optional<const ResolveContext&> context, const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, const std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>>& fstrmLoggers, const std::set<uint16_t>& exportTypes, LWResult* res, bool* chained);
index f6e0c6bb0303e9049eb894df638382b440ed3ade..587821f992c2e0bb68a4f76f8c8e2d73300beefb 100644 (file)
@@ -315,8 +315,8 @@ LWResult::Result asendto(const char* data, size_t len, int /* flags */,
   return LWResult::Result::Success;
 }
 
-LWResult::Result arecvfrom(PacketBuffer& packet, int /* flags */, const ComboAddress& fromaddr, size_t* d_len,
-                           uint16_t id, const DNSName& domain, uint16_t qtype, int fd, const struct timeval* now)
+LWResult::Result arecvfrom(PacketBuffer& packet, int /* flags */, const ComboAddress& fromaddr, size_tlen,
+                           uint16_t id, const DNSName& domain, uint16_t qtype, int fd, const struct timeval& now)
 {
   static const unsigned int nearMissLimit = ::arg().asNum("spoof-nearmiss-max");
 
@@ -327,7 +327,8 @@ LWResult::Result arecvfrom(PacketBuffer& packet, int /* flags */, const ComboAdd
   pident->type = qtype;
   pident->remote = fromaddr;
 
-  int ret = MT->waitEvent(pident, &packet, g_networkTimeoutMsec, now);
+  int ret = MT->waitEvent(pident, &packet, g_networkTimeoutMsec, &now);
+  len = 0;
 
   /* -1 means error, 0 means timeout, 1 means a result from handleUDPServerResponse() which might still be an error */
   if (ret > 0) {
@@ -336,7 +337,7 @@ LWResult::Result arecvfrom(PacketBuffer& packet, int /* flags */, const ComboAdd
       return LWResult::Result::PermanentError;
     }
 
-    *d_len = packet.size();
+    len = packet.size();
 
     if (nearMissLimit > 0 && pident->nearMisses > nearMissLimit) {
       /* we have received more than nearMissLimit answers on the right IP and port, from the right source (we are using connected sockets),