summaryrefslogtreecommitdiff
path: root/libc/inet/resolv.c
AgeCommit message (Collapse)Author
2015-12-17resolv: __dns_lookup - immediately switch to next server in case of poll() ↵Waldemar Brodkorb
set error events https://bugs.busybox.net/show_bug.cgi?id=3211 Signed-off-by: Leonid Lisovskiy <lly.dev@gmail.com> Signed-off-by: Waldemar Brodkorb <wbx@uclibc-ng.org>
2015-04-12remove link warningsWaldemar Brodkorb
As recently discussed on the pgsql mailinglist, this warnings are more or less useless and some configure scripts are failing when these warnings are enabled. http://www.postgresql.org/message-id/20150320132351.GS3636@alvh.no-ip.org
2015-03-16resolv: fix unaligned tmp buffer corner-caseAlexey Brodkin
On execution of "inet/gethost_r-align" test I noticed failure due to unaligned access (instaed of 4-byte aligned 1-byte aligned address was attempted to be accessed). Further investigation confirmed this nice and helpful test failure. Following commit removed usage of ALIGN_BUFFER_OFFSET on entry to __read_etc_hosts_r(): http://git.uclibc.org/uClibc/commit/?id=f65e66078b9f4d2d7f0fc336dee36e78fc467c0f So indeed if target architecture doesn't allow unaligned access and provided tmp buffer is not word aligned (and we will deal with pointers which means word-sized data units), then CPU will fail during execution. In case of ARC we'll see "Unaligned access" exception like this: --->8--- # potentially unexpected fatal signal 7. Path: /root/uClibc/test/inet/gethost_r-align CPU: 0 PID: 5514 Comm: gethost_r-align Not tainted 3.13.11 #2 task: 8f42a580 ti: 8f40e000 task.ti: 8f40e000 [ECR ]: 0x00230400 => Misaligned r/w from 0x5fdab341 [EFA ]: 0x5fdab341 [BLINK ]: 0x20032a18 [ERET ]: 0x20032a3c @off 0x12a3c in [/lib/libuClibc-0.9.34-git.so] VMA: 0x20020000 to 0x20062000 [STAT32]: 0x00000086 : U E2 E1 BTA: 0x20046014 SP: 0x5fdab260 FP: 0x00000000 LPS: 0x20046064 LPE: 0x20046068 LPC: 0x00000000 r00: 0x5fdab341 r01: 0x00000005 r02: 0x00000015 r03: 0x00000000 r04: 0x5fdab358 r05: 0x00000000 r06: 0x0a0a0a00 r07: 0x00000000 r08: 0x0000003f r09: 0x20067050 r10: 0x00000000 r11: 0x00000014 r12: 0x00000001 r13: 0x00000000 r14: 0x20060660 r15: 0x20060661 r16: 0x00000006 r17: 0x5fdab371 r18: 0x00000018 r19: 0x5fdab2b4 r20: 0x00020000 r21: 0x00000000 r22: 0x00029068 r23: 0x5fdab371 r24: 0x00010000 r25: 0x00000000 --->8--- To fix this problem we'll re-introduce tmp buffer force alignment before config parser invocation. Signed-off-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Waldemar Brodkorb <wbx@openadk.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2014-04-23resolv: try next server on SERVFAILMichel Stam
Commit e1420eca7374cd8f583e9d774c890645a205aaee fixed a bug where a response code should mean the next server is tried. However, it tries only the next search domain, and never skips to the next server. This fix makes sure we try the next server on SERVFAIL. Signed-off-by: Michel Stam <michel@reverze.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-12-20inet: Fix threaded res_initKenneth Soerensen
In a multi-threaded application where res_init() was called either directly or implicitly, getaddrinfo() and others failed to add the DNS search domain to hostnames. This problem made it not possible to look up a hostname without its domain appended. The problem is caused by res_sync_func() overwriting the configuration read by __open_nameservers() immediately after it is read. The suggested solutin is to disable res_sync_func() while reading name server configuration in res_init(). Signed-off-by: Kenneth Soerensen <kenneth.sorensen@spectralink.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-11-12Make res_init() thread safe.Kenneth Soerensen
res_init() was not atomic, which could give undesired behaviour. Now res_init() is completely locked under one lock and the locking is removed from __res_vinit(). Signed-off-by: Kenneth Soerensen <kenneth.sorensen@spectralink.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-11-12Fix threaded use of res_ functions.Sørensen, Kenneth
Commit aab4df0fb51660300559f5f29290709db2f7bfee says that the line with after res_init() function. Commit 7f74de5d4d6d10baafab4b37bb3d472f5c5f0e8c moves the res_init() function below the line with #undef _res. This commit moves res_init() back above #undef _res. Signed-off-by: Kenneth Soerensen <kenneth.sorensen@spectralink.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-07-19inet: fix unsafe access to _res.options in res_mkquery()Vanya Sergeev
res_mkquery() takes out __resolv_lock to copy _res.options to function local _res_options on line 4204, but later unsafely accesses _res.options without a lock, instead of its local copy _res_options, on line 4221. Looks like a period / underscore typo. Signed-off-by: Vanya Sergeev <vsergeev@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-29inet: fix getting the nameserver from _res state after res_init.Felix Fietkau
Fixes displaying the nameserver in busybox nslookup. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-20inet: do not filter responses in res_queryTimo Teräs
Fixes bug #5342 res_query was silently rejecting responses against T_ANY DNS questions. Remove the type-filtering from res_query altogether. __dns_lookup is supposed to return the proper stuff that you asked for (and only that). Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-20inet: Fix LT{.old,} compilation due to res_icloseBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-03-14inet: res_nclose: free user-buffer, not global _resBernhard Reutner-Fischer
In res_iclose we were operating on the global _res even if called via res_nclose where we are supposed to operate on the user provided res_state. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2013-02-20inet: remove noreturn attribute from res_ncloseBernhard Reutner-Fischer
Partially revert e9af4dfbd328e9f3bba235fdb2d1027dd2dbbcde Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-08-04libc/inet/resolv.c: Use IE model for TLS data.Will Newton
All other TLS data in uClibc is explicitly using the IE model, so use it for __resp too. This generates smaller and faster code. Signed-off-by: Will Newton <will.newton@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-08-04libc/inet/resolv.c: Remove obsolete comment.Will Newton
The definition of __resp has been hidden for some years (commit 22de495d). Remove the comment suggesting that it is not. Signed-off-by: Will Newton <will.newton@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c: shrink code a bit in getnameinfo.Peter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15fix a bunch of build warningsPeter S. Mazinger
Added attribute_noreturn even if it has return at the end of function Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c,time.c,_atexit.c: hide 3 locksPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c: include param.h and use MIN instead of minPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15resolv.c: remove duplicated attribute_hiddenPeter S. Mazinger
while there add one for future (currently in unused code) Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-06-15remove __FORCE_GLIBCPeter S. Mazinger
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-04-17resolv: tiny shrinkage in /etc/hosts handlingBernhard Reutner-Fischer
-4b Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-04-17resolv: remove unused variablesBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2012-04-17resolv: Fix /etc/hosts for more than MAXALIASES aliasesBernhard Reutner-Fischer
PR networking/4916 Reserve space for the terminating 0 alias and zero out the scratch-buffer so the last entry of the alias list is empty. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-11-27make ARRAY_SIZE commonly available internallyMike Frysinger
Some places have opencoded the ARRAY_SIZE macro, so move it to a global internal location so other places can leverage it. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2011-11-17resolv: hide relocationsBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-21resolv: fix memory leakBernhard Reutner-Fischer
Timothy Holdener writes: small memory leak in __dns_lookup() when the A record in the DNS answer is preceded by one or more CNAME records. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-20resolv: commentary typo fixBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-20gethostbyname_r: set correct h_errno upon failureBernhard Reutner-Fischer
previously gethostbyname_r(ipv6.google.com);herror("ERROR:") gave Answer name = |ipv6.google.com| Answer type = |5| herrno=1 h_errno=0 ERROR:: Error 0 herrno=1 h_errno=1 ERROR:: Unknown host Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-10-20resolv: fix compilationBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-09-10resolv: simple optimizations and style/readability fixesDenys Vlasenko
text data bss dec hex filename - 2915 0 0 2915 b63 libc/inet/ns_name_old.o + 2656 0 0 2656 a60 libc/inet/ns_name.o - 958 0 0 958 3be libc/inet/ns_parse_old.o + 898 0 0 898 382 libc/inet/ns_parse.o Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-08-26inet/resolv: add res_ninit and res_ncloseDaniel Mack
Some reordering of existing functions was necessary in order to provide this functionality. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add res_mkqueryDaniel Mack
Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add ns_initparse, ns_parserr, ns_skiprr and ns_msg_getflagDaniel Mack
There are build 'ifdef L_ns_parse'. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add dn_skipname and ns_name_skipDaniel Mack
One uses the other, so add them in one go. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: Add dn_compDaniel Mack
Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add ns_name_pton, ns_name_pack and ns_name_compressDaniel Mack
These are built '#ifdef L_ns_name' Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26inet/resolv: add ns_{put,get}{16,32}Daniel Mack
This patch introduces a new config directive 'UCLIBC_HAS_RESOLVER_SUPPORT' and adds the new symbols conditionally. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-08-26libc/inet/resolv.c: comment on #endif linesDaniel Mack
While reading this file, I found it rather confusing to relate the "endif" lines to their opening counter-part. This patch adds comments to most of these lines to denote what the actually do. Signed-off-by: Daniel Mack <zonque@gmail.com>
2011-06-17resolv: fix bug in res_init with ipv6 nameserversBernhard Reutner-Fischer
Thanks to Christian Krause <chkr plauener.de> for finding and fixing this! Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-06-14resolv: try next server on SERVFAILBernhard Reutner-Fischer
in bug 3637 Andrey Kovalev aka pxe.ru writes: getaddrinfo does NOT add domain to query when receive SERVFAIL RFC1035 7.2 suggests that - If a resolver gets a server error or other bizarre response from a name server, it should remove it from SLIST, and may wish to schedule an immediate transmission to the next candidate server address. So let's try the next server upon SERVFAIL even if it's not strictly required. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-04-13resolv: really fix res_close not to hang with ipv6Bernhard Reutner-Fischer
Fix goof in previous commit. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2011-04-12resolv: fix res_close not to hang with ipv6Bernhard Reutner-Fischer
Timo Teräs writes: The memory release loop is missing an obvious counter increment. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-11-23resolv.c fails for /etc/hosts lookupsPhilip Nye
Patch attached: Fix a bug in offset calculations when parsing /etc/hosts in resolv.c. Formerly a miscalculation meant that having found the correct line, the code was trashing its own result data. Signed-off-by: Philip Nye <philipn@engarts.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-08-28Fix resolver broken in NPTL buildTimo Teräs
The combination of commit aab4df0fb51660300559f5f29290709db2f7bfee resolv.c: add support for per thread res_state commit cca45baf8353d1e338d232f5bdb2d1d6b357f1da /etc/resolv.conf: support "timeout:n" and "attempts:n" options .. and NPTL results in broken resolver in very annoying ways. Now, it seems that most of the uclibc code does not work well if res_state is TLS variable. Technically, this is the correct thing to do since this gives proper per-thread resolving behavior, and it also makes the config options overridable per thread. This probably what apps expect as glibc does it too. But alas, most places use _res to sync up static global variables which results in breakage. It gets more or less randomly selected which threads options get applied. Also in case of multiple servers it looks like the retry logic is shared between all threads, e.g. two concurrent resolutions can make other resolvers skip nameservers due to shared "last_ns_num". And finally the timeout/attempts commit breaks the accumulated stuff horribly. What happens is: 1. multithreaded application startups, initializes resolver, resolves things just fine 2. resolv.conf gets changed, application calls res_init after res_init uclibc will call res_sync on all resolver functions to refresh globals from the TLS variable _res 3. res_init was called only in one thread, so other thread's _res contains all zeroes (yes, this is correct app usage: res_init should be called only from one thread) 4. threads not calling res_init get broken resolver due to timeout being set to zero Now, one proper solution would be to: 1. make __open_nameservers return the configuration options 2. pass the config options struct to res_sync_func so it can do the proper overrides from per-thread _res 3. remove the related globals and use locally config options from __open_nameservers But technically, the correct thing (as in glibc does this) is: - res_init increases global "res_init timestamp" - use _res (or pointer within there) for resolver retries etc. get proper per-thread behavior - resolvers functions call "maybe_init" which reinitialize the TLS'ed resolver state (e.g. reload resolv.conf) if their res_init timestamp is out dated As an immediate emergency kludge fix, the following might do: resolv: fix options handling for TLS _res If _res is in TLS (NPTL), it might not get initialized. Assume zeroes mean default values. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-19resolv: simplify MAXALIAS handlingBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-08-05resolver: switch to config parserBernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-07-28Immediately try next nameserver on recv() failureIngo van Lil
If there is a problem communicating with a nameserver the __dns_lookup() function will not immediately advance to the next nameserver but instead continue waiting until the timeout expires. This will cause a 30 second delay even if no nameserver is configured in resolv.conf and no DNS is running on localhost. Signed-off-by: Ingo van Lil <inguin@gmx.de> Acked-by: Roman I Khimov <khimov@altell.ru> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-05-07resolv: various memory corruption and off by one fixesTimo Teras
Fixes resolution of names with AAAA entries and gethostbyaddr issues. Signed-off-by: Timo Teras <timo.teras@iki.fi> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
2010-04-09resolv: tentatively fix usage of uninitialized DNS parametersDenys Vlasenko
See "Possible regression from timeout commit for resolv.conf" thread. Also remove superfluous NULL check. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>