aboutsummaryrefslogtreecommitdiff
path: root/resolv/res_query.c
AgeCommit message (Collapse)AuthorFilesLines
2024-01-11resolv: Fix endless loop in __res_context_queryStefan Liebler1-2/+6
Starting with commit 40c0add7d48739f5d89ebba255c1df26629a76e2 "resolve: Remove __res_context_query alloca usage" there is an endless loop in __res_context_query if __res_context_mkquery fails e.g. if type is invalid. Then the scratch buffer is resized to MAXPACKET size and it is retried again. Before the mentioned commit, it was retried only once and with the mentioned commit, there is no check and it retries in an endless loop. This is observable with xtest resolv/tst-resolv-qtypes which times out after 300s. This patch retries mkquery only once as before the mentioned commit. Furthermore, scratch_buffer_set_array_size is now only called with nelem=2 if type is T_QUERY_A_AND_AAAA (also see mentioned commit). The test tst-resolv-qtypes is also adjusted to verify that <func> is really returning with -1 in case of an invalid type. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2023-10-02resolve: Remove __res_context_query alloca usageAdhemerval Zanella1-31/+23
The bufsize on current Linux build is: size_t bufsize = (type == 439963904 ? 2 : 1) * (12 + 4 + 255 + 1); So with upper bound as 544 (2 * (12 + 4 + 255 + 1)). However, it might increase to 2 * PACKETSIZE later with malloc. The default scratch_buffer should fullfill the most usual allocation requirement. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Joe Simmons-Talbott <josimmon@redhat.com>
2022-06-24resolv: Implement no-aaaa stub resolver optionFlorian Weimer1-4/+20
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-03-22resolv: Fix unaligned accesses to fields in HEADER structJohn David Anglin1-5/+5
The structure HEADER is normally aligned to a word boundary but sometimes it needs to be accessed when aligned on a byte boundary. This change defines a new typedef, UHEADER, with alignment 1. It is used to ensure the fields are accessed with byte loads and stores when necessary. V4: Change to res_mkquery.c deleted. Small whitespace fix. V5: Move UHEADER typedef to resolv/resolv-internal.h. Replace all HEADER usage with UHEADER in resolv/res_send.c. Signed-off-by: John David Anglin <dave.anglin@bell.net> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-10-11resolv: Avoid GCC 12 false positive warning [BZ #28439].Martin Sebor1-1/+3
Replace a call to sprintf with an equivalent pair of stpcpy/strcpy calls to avoid a GCC 12 -Wformat-overflow false positive due to recent optimizer improvements.
2021-07-19resolv: Move res_query functions into libcFlorian Weimer1-32/+56
This switches to public symbols without __ prefixes, due to improved namespace management in glibc. The script was used with --no-new-version to move the symbols __res_nquery, __res_nquerydomain, __res_nsearch, __res_query, __res_querydomain, __res_search, res_query, res_querydomain, res_search. The public symbols res_nquery, res_nquerydomain, res_nsearch, res_ownok, res_query, res_querydomain, res_search were added with make update-all-abi. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-07-19resolv: Move res_hostalias into its own file, along with hostaliasFlorian Weimer1-30/+0
These deprecated symbols continue to be exported from libresolv. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-07-19resolv: Move __res_context_hostalias into its own file and into libcFlorian Weimer1-40/+0
And reformat it to GNU style. Remove the unecessary setbuf call. Use __fgets_unlocked for PLT avoidance; no locking is required here. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-07-19resolv: Move ns_samename into its own file, and into libcFlorian Weimer1-1/+1
But only as an internal symbol, __libc_ns_samename. The libresolv ABI is preserved. This is because the function is deprecated, and it does not make sense to add new symbol versions for deprecated functions. Also reformat the implementation to GNU style. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2017-07-03resolv: Lift domain search list limits [BZ #19569] [BZ #21475]Florian Weimer1-5/+6
This change uses the extended resolver state in struct resolv_conf to store the search list. If applications have not patched the _res object directly, this extended search list will be used by the stub resolver during name resolution.
2017-07-03resolv: Introduce struct resolv_context [BZ #21668]Florian Weimer1-126/+172
struct resolv_context objects provide a temporary resolver context which does not change during a name lookup operation. Only when the outmost context is created, the stub resolver configuration is verified to be current (at present, only against previous res_init calls). Subsequent attempts to obtain the context will reuse the result of the initial verification operation. struct resolv_context can also be extended in the future to store data which needs to be deallocated during thread cancellation.
2017-06-30resolv: Remove DEBUG from resolv/res_query.cFlorian Weimer1-36/+0
2017-06-30resolv: Move res_query, res_search res_querydomain, hostaliasFlorian Weimer1-1/+56
From res_data.c to query.c
2017-04-19resolv: Replace __builtin_expect with __glibc_unlikely/__glibc_likelyFlorian Weimer1-1/+1
2017-04-13resolv: Remove EDNS fallback [BZ #21369]Florian Weimer1-15/+1
EDNS is disabled by default (so there is interoperability issue), and the fallback code is problematic because it prevents an application from obtaining DNSSEC data after a FORMERR response.
2017-04-13resolv: Reduce EDNS payload size to 1200 bytes [BZ #21361]Florian Weimer1-4/+19
This hardens the stub resolver against fragmentation-based attacks.
2017-04-13resolv: Remove internal and unused definitions from <resolv.h>Florian Weimer1-0/+1
The RES_F_* constants are only used with the private _res._flags member. RES_EXHAUSTIVE is unused. The removed function declarations refer to functions not actually exported by glibc, so they are unusable by applications.
2016-12-31CVE-2015-5180: resolv: Fix crash with internal QTYPE [BZ #18784]Florian Weimer1-3/+3
Also rename T_UNSPEC because an upcoming public header file update will use that name.
2016-04-28resolv: Remove SCCS and RCS keywordsFlorian Weimer1-5/+0
2016-02-16CVE-2015-7547: getaddrinfo() stack-based buffer overflow (Bug 18665).Carlos O'Donell1-0/+3
* A stack-based buffer overflow was found in libresolv when invoked from libnss_dns, allowing specially crafted DNS responses to seize control of execution flow in the DNS client. The buffer overflow occurs in the functions send_dg (send datagram) and send_vc (send TCP) for the NSS module libnss_dns.so.2 when calling getaddrinfo with AF_UNSPEC family. The use of AF_UNSPEC triggers the low-level resolver code to send out two parallel queries for A and AAAA. A mismanagement of the buffers used for those queries could result in the response of a query writing beyond the alloca allocated buffer created by _nss_dns_gethostbyname4_r. Buffer management is simplified to remove the overflow. Thanks to the Google Security Team and Red Hat for reporting the security impact of this issue, and Robert Holiday of Ciena for reporting the related bug 18665. (CVE-2015-7547) See also: https://sourceware.org/ml/libc-alpha/2016-02/msg00416.html https://sourceware.org/ml/libc-alpha/2016-02/msg00418.html
2014-11-21BZ#16469: resolv: skip leading dot in domain to searchAlexandre Oliva1-3/+14
This should only happen if the domain to search is the root, represented as "." rather than by an empty string. Skipping it here prevents libc_res_nquerydomain from duplicating the trailing dot, which would cause the domain name compression to fail. for ChangeLog [BZ #16469] * resolv/res_query.c (__libc_res_nsearch): Skip leading dot in search domain names.
2014-11-21BZ#16469: don't drop trailing dot in res_nquerydomain(..., name, NULL, ...)Alexandre Oliva1-11/+2
If we drop it here, we will fail to detect a duplicate trailing dot later on. Retaining, OTOH, has no ill effects whatsoever, and it even saves us the trouble of copying the domain name minus the trailing dot, like we used to do. for ChangeLog [BZ #16469] * NEWS: Update. * resolv/res_query.c (__libc_res_nquerydomain): Retain trailing dot. * posix/tst-getaddrinfo5.c: New. * posix/Makefile (tests): Add it.
2014-07-08Check value at resplen2 if it is not NULLSiddhesh Poyarekar1-4/+5
There was a typo in the previous patch due to which resplen2 was checked for non-zero instead of the value at resplen2. Fix that and improve the condition by checking resplen2 for non-NULL (instead of answerp2) and also adding the check in a third place.
2014-04-30Do not fail if one of the two responses to AF_UNSPEC fails (BZ #14308)Siddhesh Poyarekar1-2/+5
[Fixes BZ #14308, #12994, #13651] AF_UNSPEC results in sending two queries in parallel, one for the A record and the other for the AAAA record. If one of these is a referral, then the query fails, which is wrong. It should return at least the one successful response. The fix has two parts. The first part makes the referral fall back to the SERVFAIL path, which results in using the successful response. There is a bug in that path however, due to which the second part is necessary. The bug here is that if the first response is a failure and the second succeeds, __libc_res_nsearch does not detect that and assumes a failure. The case where the first response is a success and the second fails, works correctly. This condition is produced by buggy routers, so here's a crude interposable library that can simulate such a condition. The library overrides the recvfrom syscall and modifies the header of the packet received to reproduce this scenario. It has two key variables: mod_packet and first_error. The mod_packet variable when set to 0, results in odd packets being modified to be a referral. When set to 1, even packets are modified to be a referral. The first_error causes the first response to be a failure so that a domain-appended search is performed to test the second part of the __libc_nsearch fix. The driver for this fix is a simple getaddrinfo program that does an AF_UNSPEC query. I have omitted this since it should be easy to implement. I have tested this on x86_64. The interceptor library source: /* Override recvfrom and modify the header of the first DNS response to make it a referral and reproduce bz #845218. We have to resort to this ugly hack because we cannot make bind return the buggy response of a referral for the AAAA record and an authoritative response for the A record. */ #define _GNU_SOURCE #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdbool.h> #include <endian.h> #include <dlfcn.h> #include <stdlib.h> /* Lifted from resolv/arpa/nameser_compat.h. */ typedef struct { unsigned id :16; /*%< query identification number */ #if BYTE_ORDER == BIG_ENDIAN /* fields in third byte */ unsigned qr: 1; /*%< response flag */ unsigned opcode: 4; /*%< purpose of message */ unsigned aa: 1; /*%< authoritive answer */ unsigned tc: 1; /*%< truncated message */ unsigned rd: 1; /*%< recursion desired */ /* fields * in * fourth * byte * */ unsigned ra: 1; /*%< recursion available */ unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */ unsigned ad: 1; /*%< authentic data from named */ unsigned cd: 1; /*%< checking disabled by resolver */ unsigned rcode :4; /*%< response code */ #endif #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN /* fields * in * third * byte * */ unsigned rd :1; /*%< recursion desired */ unsigned tc :1; /*%< truncated message */ unsigned aa :1; /*%< authoritive answer */ unsigned opcode :4; /*%< purpose of message */ unsigned qr :1; /*%< response flag */ /* fields * in * fourth * byte * */ unsigned rcode :4; /*%< response code */ unsigned cd: 1; /*%< checking disabled by resolver */ unsigned ad: 1; /*%< authentic data from named */ unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */ unsigned ra :1; /*%< recursion available */ #endif /* remaining * bytes * */ unsigned qdcount :16; /*%< number of question entries */ unsigned ancount :16; /*%< number of answer entries */ unsigned nscount :16; /*%< number of authority entries */ unsigned arcount :16; /*%< number of resource entries */ } HEADER; static int done = 0; /* Packets to modify. 0 for the odd packets and 1 for even packets. */ static const int mod_packet = 0; /* Set to true if the first request should result in an error, resulting in a search query. */ static bool first_error = true; static ssize_t (*real_recvfrom) (int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); void __attribute__ ((constructor)) init (void) { real_recvfrom = dlsym (RTLD_NEXT, "recvfrom"); if (real_recvfrom == NULL) { printf ("Failed to get reference to recvfrom: %s\n", dlerror ()); printf ("Cannot simulate test\n"); abort (); } } /* Modify the second packet that we receive to set the header in a manner as to reproduce BZ #845218. */ static void mod_buf (HEADER *h, int port) { if (done % 2 == mod_packet || (first_error && done == 1)) { printf ("(Modifying header)"); if (first_error && done == 1) h->rcode = 3; else h->rcode = 0; /* NOERROR == 0. */ h->ancount = 0; h->aa = 0; h->ra = 0; h->arcount = 0; } done++; } ssize_t recvfrom (int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen) { ssize_t ret = real_recvfrom (sockfd, buf, len, flags, src_addr, addrlen); int port = htons (((struct sockaddr_in *) src_addr)->sin_port); struct in_addr addr = ((struct sockaddr_in *) src_addr)->sin_addr; const char *host = inet_ntoa (addr); printf ("\n*** From %s:%d: ", host, port); mod_buf (buf, port); printf ("returned %zd\n", ret); return ret; }
2014-04-11Fix typo in comment in res_query.cJoseph Anthony Pasquale Holsten1-1/+1
2014-02-19Properly fix memory leak in _nss_dns_gethostbyname4_r with big DNS answerAndreas Schwab1-19/+26
Instead of trying to guess whether the second buffer needs to be freed set a flag at the place it is allocated
2014-02-10Use glibc_likely instead __builtin_expect.Ondřej Bílka1-1/+1
2012-11-30Fix assertion failures in resolver (BZ #13013).Aurelien Jarno1-15/+15
[BZ #13013] * resolv/res_query.c(__libc_res_nquery): Assign hp and hp2 depending n and resplen2 to catch cases where answer equals answerp2.
2012-02-29[network] Avoid out ouf bounds read in __libc_res_nquerydomainJeff Law1-3/+7
2012-02-28 Jeff Law <law@redhat.com> * resolv/res_query.c (__libc_res_nquerydomain): Avoid out of bounds read.
2011-11-15Clean up internal fopen usesUlrich Drepper1-1/+1
No need to ever not use c and e.
2011-07-20Use size_t for strlen resultsAndreas Schwab1-1/+1
2011-05-07Backport BIND code to query name as TLD.Ulrich Drepper1-6/+8
2009-07-27Define and implement RES_USE_DNSSEC option in resolver.Adam Tkac1-4/+4
2009-05-09[BZ #10128]Ulrich Drepper1-0/+7
2009-05-05 Aurelien Jarno <aurelien@aurel32.net> [BZ #10128] * resolv/res_query.c (__libc_res_nquery): If one query returns NOTIMP or FORMERR and the other NOERROR, don't raise an error.
2008-10-24Fix tests for existence of second reply.Ulrich Drepper1-3/+3
2008-10-24* resolv/res_query.c (__libc_res_nquery): Add a few casts.Ulrich Drepper1-4/+4
2008-07-28* resolv/res_send.c (__libc_res_nsend): Take additional parameter.cvs/fedora-glibc-20080728T2320Ulrich Drepper1-13/+19
Use it instead of locally defined resplen2 variable. (res_nsend): Adjust for __libc_res_nsend interface change. (send_vc): Initialize *resplen2 if necessary. Read length of package into an appropriately aligned variable. Store converted length in new variable and use it appropriately. Add branch prediction help. * resolv/res_query.c (__libc_res_nquery): Take additional parameter and pass it on to __libc_res_nsend. Adjust all callers. (__libc_res_nsearch): Likewise. (__libc_res_nqeurydomain): Likewise. * resolv/nss_dns/dns-host.c: Adjust for __libc_res_nsearch interface change. (_nss_dns_gethostbyname4): Don't unconditionally allocate tmp array. Define resplen2 variable and pass it to __libc_res_nsearch and then to gaih_getanswer. (getanswer_r): In case of incorrect DNS data don't overread buffer. Add branch prediction. (gaih_getanswer_slice): Likewise. Check for invalid data types. (gaih_getanswer): Don't decode second slice if first one failed due to a too small buffer. Don't let not found status of second decoder shadow results of the first. * resolv/gethnamaddr.c (gethostbyname2): Adjust for __libc_res_nsearch and __libc_res_nquery interface changes (gethostbyaddr): Adjust for __libc_res_nquery interface change. * include/resolv.h: Adjust prototypes for __libc_res_nquery, __libc_res_nsearch, and __libc_res_nsend. * resolv/nss_dns/dns-canon.c: Adjust for __libc_res_nquery interface change. * resolv/nss_dns/dns-network.c: Adjust for __libc_res_nquery and __libc_res_nsearch interface changes.
2008-07-09* resolv/res_query.c (__libc_res_nquery): Issue debug message onlyUlrich Drepper1-2/+4
if DEBUG is defined.
2008-07-09* resolv/res_query.c (__libc_res_nquery): Align buffer for T_AAAAUlrich Drepper1-4/+20
query. Adjust buffer size computation for padding.
2008-05-19* resolv/res_query.c (__libc_res_nquery): In case one of twoUlrich Drepper1-0/+15
answer was too short don't try to read that answer's header. * resolv/res_send.c (send_dg): In case of timeout and there are two queries and one has been answered, return value indicating success.
2008-05-10* include/resolv.h: Adjust __libc_res_nquery and __libc_res_nsendUlrich Drepper1-35/+114
prototypes. * include/arpa/nameser_compat.h: Define T_UNSPEC. * nis/Versions (libnss_nis): Export _nss_nis_gethostbyname4_r. (libnss_nisplus): Export _nss_nisplus_gethostbyname4_r. * nis/nss_nis/nis-hosts.c (LINE_PARSER): Change to also handle af==AF_UNSPEC. (_nss_nis_gethostbyname4_r): New function. * nis/nss_nisplus/nisplus-hosts.c (_nss_nisplus_parse_hostent): Change to also handle af==AF_UNSPEC. (get_tablename): New function. Use it to avoid duplication. (_nss_nisplus_gethostbyname4_r): New function. * nscd/aicache.c (addhstaiX): Use gethostbyname4_r function is available. * nss/Versions (libnss_files): Export _nss_files_gethostbyname4_r. * nss/nss.h: Define struct gaih_addrtuple. * nss/nss_files/files-hosts.c (LINE_PARSER): Change to also handle af==AF_UNSPEC. (_nss_files_gethostbyname4_r): New function. * resolv/Versions (libnss_dns): Export _nss_dns_gethostbyname4_r. * resolv/gethnmaddr.c: Adjust __libc_res_nsearch and __libc_res_nquery calls. * resolv/res_query.c (__libc_res_nquery): Take two additional parameters for second answer buffer. Handle type=T_UNSPEC to mean look up IPv4 and IPv6. Change all callers. * resolv/res_send.c (__libc_res_nsend): Take five aditional parameters for an additional query and answer buffer. Pass to send_vc and send_dg. (send_vc): Send possibly two requests and receive two answers. (send_dg): Likewise. * resolv/nss_dns/dns-host.c: Adjust calls to __libc_res_nsearch and __libc_res_nquery. (_nss_dns_gethostbyname4_r): New function. (gaih_getanswer_slice): Likewise. (gaih_getanswer): Likewise. * resolv/nss_dns/dns-canon.c (_nss_dns_getcanonname_r): Adjust __libc_res_nquery call. * resolv/nss_dns/dns-network.c (_nss_dns_getnetbyaddr_r): Likewise. (_nss_dns_getnetbyname_r): Adjust __libc_res_nsearch call. * sysdeps/posix/getaddrinfo.c: Use gethostbyname4_r function is available.
2007-02-09* resolv/res_init.c (res_setoptions): Recognize edns0 option.Ulrich Drepper1-7/+22
* resolv/res_mkquery.c: Define __res_nopt. * resolv/res_query.c (__libc_res_nquery): If RES_USE_EDNS0 is set try adding EDNS0 record. * resolv/res_send.c (send_dg): If request failed with FORMERR and EDNS0 record was send make sure we don't try it again. * resolv/resolv.h: Define RES_F_EDNS0ERR and RES_USE_EDNS0. * include/resolv.h: Declare __res_nopt.
2006-05-06[BZ #2499]Ulrich Drepper1-0/+6
2006-05-06 Ulrich Drepper <drepper@redhat.com> [BZ #2499] * resolv/res_query.c (__libc_res_nquery): If answerp != NULL, __libc_res_nsend might reallocate the buffer for the answer. In this case we have to reload the HP pointer.
2004-12-22(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.Ulrich Drepper1-6/+0
2007-07-122.5-18.1Jakub Jelinek1-0/+6
2004-10-18Update.Ulrich Drepper1-0/+6
2004-10-17 Ulrich Drepper <drepper@redhat.com> * include/libc-symbols.h: Define libresolv_hidden_proto and friends. * include/resolv.h: Add libresolv_hidden_proto for symbols defined, used, and exported in libresolv. * resolv/base64.c: Add libresolv_hidden_def. * resolv/gethnamaddr.c: Likewise. * resolv/ns_name.c: Likewise. * resolv/ns_netint.c: Likewise. * resolv/res_comp.c: Likewise. * resolv/res_data.c: Likewise. * resolv/res_debug.c: Likewise. * resolv/res_mkquery.c: Likewise. * resolv/res_query.c: Likewise. * resolv/res_send.c: Likewise.
2004-08-12Update.Ulrich Drepper1-2/+5
2004-08-12 Jakub Jelinek <jakub@redhat.com> * resolv/res_query.c (__libc_res_nsearch): Protect the debugging printf with #ifdef DEBUG and RES_DEBUG check. * sysdeps/unix/sysv/linux/bits/shm.h: Move __END_DECLS after __USE_MISC #endif. * sysdeps/generic/bits/shm.h: Add __BEGIN_DECLS for __getpagesize declaration. * sysdeps/gnu/bits/shm.h: Likewise. * sysdeps/unix/sysv/linux/alpha/bits/shm.h: Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/shm.h: Likewise. * sysdeps/unix/sysv/linux/s390/bits/shm.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/shm.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/bits/shm.h: Likewise.
2004-08-09[BZ #116]Ulrich Drepper1-6/+1
Update. * elf/dl-load.c (_dl_map_object): If __RTLD_CALLMAP flag is set, reset loader before the actual loading. * elf/dl-open.c (dl_open_worker): If file name contains no path element determine map of caller. Pass caller map in this case to _dl_map_object. Set __RTLD_CALLMAP in mode. * include/dlfcn.h (__RTLD_CALLMAP): Define. [BZ #116] Patch by Greg Wolodkin <greg@mathworks.com>.
2004-08-09[BZ #95]Ulrich Drepper1-3/+11
Update. * resolv/res_query.c (__libc_res_nsearch): Correctly test whether name contains any dots. [BZ #95]
2002-10-17Update.Ulrich Drepper1-31/+88
2002-10-15 Jakub Jelinek <jakub@redhat.com> * include/resolv.h (__libc_res_nquery, __libc_res_nsearch, __libc_res_nsend): New prototypes. * resolv/res_query.c (QUERYSIZE): Define. (__libc_res_nquery): Renamed from res_nquery. Added answerp argument. Allocate only QUERYSIZE bytes first, if res_nmkquery fails use MAXPACKET buffer. Call __libc_res_nsend instead of res_nsend, pass answerp. (res_nquery): Changed into wrapper around __libc_res_nquery. (__libc_res_nsearch): Renamed from res_nsearch. Added answerp argument. Call __libc_res_nquerydomain and __libc_res_nquery instead of the non-__libc_ variants, pass them answerp. (res_nsearch): Changed into wrapper around __libc_res_nsearch. (__libc_res_nquerydomain): Renamed from res_nquerydomain. Added answerp argument. Call __libc_res_nquery instead of res_nquery, pass answerp. (res_nquerydomain): Changed into wrapper around __libc_res_nquerydomain. * resolv/res_send.c: Include sys/ioctl.h. (MAXPACKET): Define. (send_vc): Change arguments. Reallocate answer buffer if it is too small. (send_dg): Likewise. (__libc_res_nsend): Renamed from res_nsend. Added ansp argument. Reallocate answer buffer if it is too small and hooks are in use. Adjust calls to send_vc and send_dg. (res_nsend): Changed into wrapper around __libc_res_nsend. * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r): Allocate just 1K answer buffer on the stack, use __libc_res_nsearch instead of res_nsearch. (_nss_dns_gethostbyaddr_r): Similarly with __libc_res_nquery. * resolv/nss_dns/dns-network.c (_nss_dns_getnetbyaddr_r): Likewise. (_nss_dns_getnetbyname_r): Similarly with __libc_res_nsearch. * resolv/gethnamaddr.c (gethostbyname2): Likewise. (gethostbyaddr): Similarly with __libc_res_nquery. * resolv/Versions (libresolv): Export __libc_res_nquery and __libc_res_nsearch at GLIBC_PRIVATE.