libc/resolve: Fix broken EDNS option
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 20 Oct 2015 12:40:52 +0000 (20:40 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 21 Oct 2015 01:13:21 +0000 (09:13 +0800)
commit3484c4aa8f394b9ac6147d925d119ffb4cd9edb6
tree22eccc8f2fa099f022178e11b37f5045da90d81a
parentfbd8bce8dd17c9bc76b9b9689ac41f7ad2ec96ea
libc/resolve: Fix broken EDNS option

EDNS option broken with unbound.  struct querybuf in net/gethnamaddr.c
defines MAXPACKET to 64K.  This in turn gets passed down until it
reached res_nopt(..., answer, anslen), where the size of the buffer
must fit in 16 bits.  Unfortunately we end up being one more than the
max so we end up sending a 0 as the size and unbound does not like
that. Instead we clip now to 64K - 1, and everyone is happy.

Obtained-from: NetBSD
DragonFly-bug: http://bugs.dragonflybsd.org/issues/2846
lib/libc/resolv/res_mkquery.c