]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Check the size of the query when re-sending a DoH query
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 8 Dec 2021 14:36:37 +0000 (15:36 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 8 Dec 2021 14:36:37 +0000 (15:36 +0100)
When the UDP response to a DoH query was truncated, we re-send the
query via TCP, passing it to a TCP worker. We need to edit the ID
to its original value before that, and while there is no reason
that the query is smaller than a dnsheader, we need to check its size,
not the size of the response.

pdns/dnsdistdist/doh.cc

index 3bfd66a0087820291d1374afb39e5c91dad23be4..268e6f97d30e444c3fa2380b22050b1cab55afb8 100644 (file)
@@ -1320,7 +1320,7 @@ static void on_dnsdist(h2o_socket_t *listener, const char *err)
       continue;
     }
 
-    if (!du->tcp && du->truncated && du->response.size() > sizeof(dnsheader)) {
+    if (!du->tcp && du->truncated && du->query.size() > sizeof(dnsheader)) {
       /* restoring the original ID */
       dnsheader* queryDH = reinterpret_cast<struct dnsheader*>(du->query.data() + du->proxyProtocolPayloadSize);
       queryDH->id = du->ids.origID;