summaryrefslogtreecommitdiffstats
path: root/libc/inet
Commit message (Collapse)AuthorAgeFilesLines
* getaddrinfo: allow numeric service without any hintsNatanael Copa2011-12-231-7/+0
| | | | | | | | | | | | | | This appears to correspond to what glibc does and this fixes an issue with iptables-1.4.11 with udp and raw port numbers. (see http://bugzilla.netfilter.org/show_bug.cgi?id=721) This fixes #3841 https://bugs.busybox.net/show_bug.cgi?id=3841 Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> (cherry picked from commit bc3be18145e4d57e7268506f123c0f0f373a15e2)
* resolv: fix resolver to return TRY_AGAIN on timeoutTimo Teräs2011-12-231-46/+49
| | | | | | | | | | | | | | | | | | | | | This fixes the internal __dns_lookup to get a h_errno pointer so it works nicely with the _r variants. Additionally the function is modified to permanent error if the static buffer lengths are not enough. And finally it fixed to return TRY_AGAIN if the nameservers timeout. res_search is fixed to continue searching if we receive TRY_AGAIN. It could be a problem with the specific search domain's server and not necessarily a problem in the recursive resolver we are querying. For same reason, it does not make sense to differentiate timeout or SERVFAIL error reply. The biggest issue this fixes is that we now properly set h_errno to TRY_AGAIN if upstream nameserver(s) timed out. Previously we would have returned NETDB_INTERNAL. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
* resolv: fix memory leakBernhard Reutner-Fischer2011-12-231-0/+2
| | | | | | | | | 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> (cherry picked from commit bb8d500a75a3050fe3198773ce7b07f669fe8f13)
* resolv: res_query for CNAMEsTimo Teräs2011-12-231-5/+3
| | | | | | | | | | | | | From: http://lists.busybox.net/pipermail/uclibc/2009-June/042583.html I had postfix failing for domains with MX->CNAME->A chain. In glibc it works. I tracked it to be a problem in uclibc res_query. It returns bogus data for CNAME entries, apparently intentionally, which is wrong. glibc return CNAME entries even for CNAME queries and most applications rely on this. So we should do the same in uclibc. Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
* linux_specific: handle accept4 and pipe2Bernhard Reutner-Fischer2011-05-121-2/+1
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* accept4: Implement cancellationBernhard Reutner-Fischer2011-05-114-19/+52
| | | | | | | .. and add proper prototype, move it into it's own obj and other such cleanups. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* Implement accept4 system call.Thierry Reding2011-05-112-0/+19
| | | | | Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* getaddrinfo.c: fix incorrect check for ERANGE from gethostbyaddr_rDenys Vlasenko2011-05-031-2/+2
| | | | | | | Also, freeaddrinfo(NULL) is ok, no need to check parameted for NULL before calling it. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* getaddrinfo.c: improve code readability. No functional changesDenys Vlasenko2011-05-031-26/+30
| | | | Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
* ether_aton: reject invalid inputBernhard Reutner-Fischer2011-05-021-2/+4
| | | | | | fixes PR2227 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* resolv: really fix res_close not to hang with ipv6Bernhard Reutner-Fischer2011-04-131-2/+2
| | | | | | Fix goof in previous commit. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* resolv: fix res_close not to hang with ipv6Bernhard Reutner-Fischer2011-04-121-1/+1
| | | | | | | 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>
* sunrpc: fix spurious fall-throughMark Salter2011-03-093-0/+3
| | | | | | | Fix spurious fall-through. Signed-off-by: Mark Salter <msalter@redhat.com> Signed-off-by: Bernd Schmidt <bernds@codesourcery.com>
* simplify ffs* codePeter S. Mazinger2011-03-061-1/+2
| | | | | | Remove __libc_ffs*, unneeded Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* Implement ffsl and ffsll.Bernd Schmidt2011-03-051-1/+1
| | | | | | | | | This imports and adapts ffsll.c from glibc. The same mechanism as in glibc is used to choose between ffs and ffsll to implement ffsl. The single user in libc is changed to use the hidden version __libc_ffs. Signed-off-by: Bernd Schmidt <bernds@codesourcery.com> Acked-by: Bernhard Reutner-Fischer <aldot@uclibc.org>
* guard IPv6 stuffPeter S. Mazinger2011-03-033-0/+18
| | | | | | disable IPv6 related stuff if feature is disabled. Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
* libc/inet/netlinkaccess.h: Use the types from kernelKhem Raj2011-01-011-8/+1
| | | | Signed-off-by: Khem Raj <raj.khem@gmail.com>
* resolv.c fails for /etc/hosts lookupsPhilip Nye2010-11-231-8/+12
| | | | | | | | | | | | 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>
* getproto: increase line buffer size, simlify and fix alias handlingNatanael Copa2010-10-141-17/+8
| | | | | | | | We increase line buffer size, reduce MAXALIASES and make sure we don't segfault when there are too manuy aliases in /etc/protocols. Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* getnet: simplify alias handling and reduce MAXALIASESNatanael Copa2010-10-141-17/+8
| | | | | | | | | | Reduce MAXALIASES to something lower. There will probably never be need for more than 1 alias but we allow a few extra. While here we alos fix segfault when there are too many aliases. Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* getservice: fix handling of long linesNatanael Copa2010-10-141-22/+16
| | | | | | | | | | | | | | | Don't try to be smart by dynamically realloc buffersize as it doesn't work. Instead, be simple and allocate a buffer big enough. This fixes a memory leak when calling getserv{ent,byname,byport} multiple times. To save memory we reduce number of max aliases. We seldomly will need more than 1 anyways. While here, fix segfault that happened if there were too many aliases. Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* getservice: getservent_r must return ERANGE when buffer is too smallNatanael Copa2010-10-141-3/+2
| | | | | | | | | | | | | | | | | | | This fixes issue introduced by 72e1a1ce186c39f07282398e2af9eb0253e60f15 This should also fix the following testcase to exit with error rather than cause an endless loop. int main(void) { if (getservbyname("non-existing", "udp") == NULL) err(1, "getservbyname"); return 0; } Reported by Pirmin Walthert http://lists.uclibc.org/pipermail/uclibc/2010-August/044277.html Signed-off-by: Natanael Copa <natanael.copa@gmail.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* libc: Handle cancellation in non multiplexed socket callsCarmelo Amoroso2010-09-171-17/+122
| | | | | | | | | | For those archs that provide non multiplexed socket calls it possible to implement the lib C wrappers without calling the multi-purpose __socketcall. For a subset of these functions that are cancellation point, it needs to correctly handle cancellation. Signed-off-by: Francesco Rundo <francesco.rundo@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
* Fix resolver broken in NPTL buildTimo Teräs2010-08-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* resolv: simplify MAXALIAS handlingBernhard Reutner-Fischer2010-08-191-16/+7
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* getserv: fix reading services lines w > 80 charsBernhard Reutner-Fischer2010-08-191-24/+23
| | | | | | e.g. getservbyname() Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* resolver: switch to config parserBernhard Reutner-Fischer2010-08-051-136/+119
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* getnet: switch to config parserBernhard Reutner-Fischer2010-08-055-222/+218
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* getproto: switch to config parserBernhard Reutner-Fischer2010-08-051-212/+137
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* switch getservice to config parserBernhard Reutner-Fischer2010-08-051-212/+139
| | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* Immediately try next nameserver on recv() failureIngo van Lil2010-07-281-1/+3
| | | | | | | | | | | | 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>
* new helper funcs for alloca/malloc with mmu/nommuMike Frysinger2010-07-271-46/+14
| | | | | | | | | | | | | The rpc rcmd code has some ugly ifdef mazes to handle mmu/nommu differences just to select alloca or malloc. Unify those with some helper macros in a new header, and then convert the rcmd code over to it. This is all geared towards fixing the getdents helper functions which only use alloca() atm. Now that we have helper functions, convert the getdents functions over too. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reviewed-by: Steven J. Magnani <steve@digidescorp.com>
* resolv: various memory corruption and off by one fixesTimo Teras2010-05-071-4/+8
| | | | | | | 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>
* fix a few build errors for the no threads caseAustin Foxley2010-04-281-0/+2
| | | | Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
* libc: Remove compiler warning due to old-style function definitionCarmelo Amoroso2010-04-2518-149/+66
| | | | Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
* Merge remote branch 'origin/master' into nptlAustin Foxley2010-04-121-4/+2
|\ | | | | | | | | | | | | Conflicts: libc/unistd/confstr.c Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * resolv: tentatively fix usage of uninitialized DNS parametersDenys Vlasenko2010-04-091-4/+2
| | | | | | | | | | | | | | See "Possible regression from timeout commit for resolv.conf" thread. Also remove superfluous NULL check. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge commit 'origin/master' into nptlAustin Foxley2010-04-061-3/+1
|\| | | | | | | | | | | | | | | Conflicts: libc/misc/utmp/utent.c libc/sysdeps/linux/i386/bits/syscalls.h Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * Fix use-after-free bug in __dns_lookupGabor Juhos2010-04-061-3/+1
| | | | | | | | | | | | | | | | | | | | | | If the type of the first answer does not match with the requested type, then the dotted name was freed. If there are no further answers in the DNS reply, this pointer was used later on in the same function. Additionally it is passed to the caller, and caused strange behaviour. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* | Merge commit 'origin/master' into nptlAustin Foxley2010-04-023-6/+22
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: Makefile.in extra/Configs/Config.in libc/sysdeps/linux/common/bits/kernel-features.h libc/sysdeps/linux/common/poll.c libc/sysdeps/linux/common/sysdep.h libc/sysdeps/linux/sh/sysdep.h Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * resolv: DEBUG-print nameserver we talk toBernhard Reutner-Fischer2010-03-301-2/+18
| | | | | | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
| * prettify make cleanBernhard Reutner-Fischer2010-03-252-4/+4
| | | | | | | | Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
* | Merge commit 'origin/master' into nptlAustin Foxley2010-02-051-13/+41
|\| | | | | | | Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
| * /etc/resolv.conf: support "timeout:n" and "attempts:n" optionsDenys Vlasenko2010-02-031-13/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | text data bss dec hex filename - 1745 2 4 1751 6d7 libc/inet/dnslookup.o + 1760 2 4 1766 6e6 libc/inet/dnslookup.o - 962 0 4 966 3c6 libc/inet/opennameservers.o + 1099 0 4 1103 44f libc/inet/opennameservers.o - 462 4 472 938 3aa libc/inet/res_init.o + 454 4 468 926 39e libc/inet/res_init.o - 870 0 0 870 366 libc/inet/res_query.o + 867 0 0 867 363 libc/inet/res_query.o Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge commit 'origin/master' into nptlKhem Raj2010-02-011-1/+1
|\| | | | | | | | | | | | | Conflicts: libc/stdlib/Makefile.in Signed-off-by: Khem Raj <raj.khem@gmail.com>
| * errno: hide __libc_resp, __libc_errno, and __libc_h_errnoKhem Raj2010-02-011-1/+1
| | | | | | | | Signed-off-by: Khem Raj <raj.khem@gmail.com>
* | Merge branch 'master' into nptlCarmelo Amoroso2010-01-2537-108/+82
|\| | | | | | | | | | | | | | | | | | | Conflicts: libc/inet/Makefile.in libc/inet/hostid.c Synchronise nptl branch with master branch @ c4b750195714ec7c10aa4de15610c5aae0751c1c Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
| * gethostid: switch to getaddrinfo and shrinkBernhard Reutner-Fischer2010-01-241-41/+26
| | | | | | | | | | | | | | | | text data bss dec hex filename 382 0 0 382 17e libc/inet/hostid.os.old 326 0 0 326 146 libc/inet/hostid.os Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
| * getprotoent_r: use correct define for return valueBernhard Reutner-Fischer2010-01-231-1/+1
| | | | | | | | | | | | Doesn't correctly set result=NULL on error or EOF. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
| * libc/inet: mark other odd /etc/conf/ spotBernhard Reutner-Fischer2010-01-231-0/+2
| | | | | | | | | | | | and wrap it in FALLBACK_TO_CONFIG_RESOLVCONF too. -24b Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>