BUG/MEDIUM: dns: don't store dns_build_query() result in the trash's length

By convenience or laziness we used to store dns_build_query()'s return code
into trash.data. The result checks applied there compare trash.data to -1
while it's now unsigned since commit 843b7cb ("MEDIUM: chunks: make the
chunk struct's fields match the buffer struct"). Let's clean this up
and test the result itself without storing it first.

No backport is needed.
This commit is contained in:
Willy Tarreau 2018-08-22 04:52:02 +02:00
parent 9c768fdca1
commit f6ee9dc616

View File

@ -1674,20 +1674,20 @@ static void dns_resolve_send(struct dgram_conn *dgram)
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
list_for_each_entry(res, &resolvers->resolutions.curr, list) {
int ret;
int ret, len;
if (res->nb_queries == resolvers->nb_nameservers)
continue;
trash.data = dns_build_query(res->query_id, res->query_type,
resolvers->accepted_payload_size,
res->hostname_dn, res->hostname_dn_len,
trash.area, trash.size);
if (trash.data == -1)
len = dns_build_query(res->query_id, res->query_type,
resolvers->accepted_payload_size,
res->hostname_dn, res->hostname_dn_len,
trash.area, trash.size);
if (len == -1)
goto snd_error;
ret = send(fd, trash.area, trash.data, 0);
if (ret != trash.data)
ret = send(fd, trash.area, len, 0);
if (ret != len)
goto snd_error;
ns->counters.sent++;