QDnsLookup/Unix: fix buffer size on sending DNS queries

Commit f2f00b2a4632aaeb58e6cdae7faef9e0bafaff49 ("QDnsLookup: implement
DNS-over-TLS") added the use of QSpan, but confounded the size of the
buffer array with the size of the query we prepared. The queryLength
variable was never used after checking if the preparation had failed.

Task-number: QTBUG-127073
Change-Id: Iac1ff680887641888e00fffd17e0e49faab1d579
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 59133b16cd3adffc70833bb2b81332c9649fa51e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-07-10 08:47:12 -07:00 committed by Qt Cherry-pick Bot
parent c3477a7375
commit 091d732b15

View File

@ -250,14 +250,15 @@ void QDnsLookupRunnable::query(QDnsLookupReply *reply)
return reply->makeResolverSystemError();
// Perform DNS query.
QSpan query(qbuffer.data(), queryLength);
ReplyBuffer buffer(ReplyBufferSize);
int responseLength = -1;
switch (protocol) {
case QDnsLookup::Standard:
responseLength = sendStandardDns(reply, &state, qbuffer, buffer, nameserver, port);
responseLength = sendStandardDns(reply, &state, query, buffer, nameserver, port);
break;
case QDnsLookup::DnsOverTls:
if (!sendDnsOverTls(reply, qbuffer, buffer))
if (!sendDnsOverTls(reply, query, buffer))
return;
responseLength = buffer.size();
break;