]> git.ipfire.org Git - thirdparty/grub.git/commit
net/dns: Fix lookup error when no IPv6 is returned
authorRenaud Métrich <rmetrich@redhat.com>
Wed, 3 May 2023 10:21:31 +0000 (12:21 +0200)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 17 May 2023 16:19:01 +0000 (18:19 +0200)
commit1be86fae1587cb8c53c2327971c8fc94fcb3234e
tree21dbab4a3e16e74dac701eedc61f8c356af16ec6
parent52a02dd24d79ed42ece44a7f3cb0ac62e97e8c9e
net/dns: Fix lookup error when no IPv6 is returned

When trying to resolve DNS names into IP addresses, the DNS code fails
from time to time with the following error:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
error: ../../grub-core/net/dns.c:688:no DNS record found.
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This happens when both IPv4 and IPv6 queries are performed against the
DNS server (e.g. 8.8.8.8) but there is no IP returned for IPv6 query, as
shown below:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
grub> net_del_dns 192.168.122.1
grub> net_add_dns 8.8.8.8
grub> net_nslookup ipv4.test-ipv6.com
error: ../../grub-core/net/dns.c:688:no DNS record found.
grub> net_nslookup ipv4.test-ipv6.com
216.218.228.115
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The root cause is the code exiting prematurely when the data->addresses
buffer has been allocated in recv_hook(), even if there was no address
returned last time recv_hook() executed.

Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/net/dns.c