]> git.ipfire.org Git - thirdparty/grub.git/commit
dns: fix buffer overflow for data->addresses in recv_hook
authorAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 26 Jul 2016 17:38:58 +0000 (20:38 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Tue, 26 Jul 2016 17:38:58 +0000 (20:38 +0300)
commit52408aa94604466bdd80f48fa8d68378a1ffab31
tree5a50ca0502d90132e0fd34895be50371fb2091b6
parent58590cb2ef48c6e85a8afeda01c385efc8c693bc
dns: fix buffer overflow for data->addresses in recv_hook

We may get more than one response before exiting out of loop in
grub_net_dns_lookup, but buffer was allocated for the first response only,
so storing answers from subsequent replies wrote past allocated size.
We never really use more than the very first address during lookup so there
is little point in collecting all of them. Just quit early if we already have
some reply.

Code needs serious redesign to actually collect multiple answers
and select the best fit according to requested type (IPv4 or IPv6).

Reported and tested by Michael Chang <mchang@suse.com>
grub-core/net/dns.c