]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Hardened DoH3 internal error handling for cpq 17117/head
authorRon Lauren Hombre <118486316+ronhombre@users.noreply.github.com>
Wed, 8 Apr 2026 02:21:02 +0000 (10:21 +0800)
committerGitHub <noreply@github.com>
Wed, 8 Apr 2026 02:21:02 +0000 (10:21 +0800)
Added a check for cpq before releasing DU to handle exceptional cases.

Signed-off-by: Ron Lauren Hombre <118486316+ronhombre@users.noreply.github.com>
pdns/dnsdistdist/doh3.cc

index 74784acf3ce75dd56c152bd33fda9db2eede2b16..18b1dc275e894d88b8b5cba0de9c152317051371 100644 (file)
@@ -661,10 +661,13 @@ static void processDOH3Query(DOH3UnitUniquePtr&& doh3Unit)
     if (downstream->passCrossProtocolQuery(std::move(cpq))) {
       return;
     }
-    // NOLINTNEXTLINE(bugprone-use-after-move): it was only moved if the call succeeded
-    unit = cpq->releaseDU();
-    unit->status_code = 500;
-    handleImmediateResponse(std::move(unit), "DoH3 internal error");
+
+    /* On exceptional cases, cpq is moved but returns false above. So we check to make sure. See https://github.com/PowerDNS/pdns/issues/17109 */
+    if (cpq) {
+      unit = cpq->releaseDU();
+      unit->status_code = 500;
+      handleImmediateResponse(std::move(unit), "DoH3 internal error");
+    }
     return;
   }
   catch (const std::exception& e) {