Issue
Description of problem:
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< --------
Digging into this, I found that the Grub code exits prematurely when the data->addresses buffer has been allocated in recv_hook(), even if there was no address returned last time recv_hook() executed.
Version-Release number of selected component (if applicable):
All grub2 releases
How reproducible:
See above.
Steps to Reproduce:
1. Network boot a UEFI system with grubx64.efi
2. Change DNS server as above
3. Repeatedly execute "net_nslookup ipv4.test-ipv6.com"
Actual results:
Sometimes error, sometimes "216.218.228.115"
Expected results:
Always "216.218.228.115" returned