Created attachment 713 [details] Proposed patch I discover that an old 1468 issue (http://lists.busybox.net/pipermail/uclibc-cvs/2007-August/024363.html) which probably lost in bugzilla, was not fixed completely in commit http://git.uclibc.org/uClibc/commit/?id=f09a1461fe8f3511750ad91f164b2769225858f5 In my case, DNS returned 30 records, which fits in 512 bytes buffer successfully, but later can't be decoded in gethostbyname_r() - internal error is ERANGE ("buffer too small for all addresses"). Sample ISP host used - unlim.is74.ru Proposed patch increases static buffer in gethostbyname() up to required value and saves 0.5k static buffer space in case of IPv6 turned on.
Created attachment 723 [details] Proposed patch - 2 Improved resolv-fix-2.patch use common shared buffer, allocated by __uc_malloc(), for gethostbyname, gethostbyname2, gethostbyaddr, gethostent non-reentrant functions. This saves approx. 1.5k of static space in .bss
Created attachment 1309 [details] smallish example works fine on current master. $ ./xgcc.sh -DNAME2 -Os -o gethostbyname2 gethostbyname.c $ ./gethostbyname2 unlim.is74.ru name : unlim.is74.ru fam : 2 addrlen: 4 addr : 78.29.3.115 addr : 78.29.3.116 addr : 78.29.3.117 addr : 78.29.3.118 addr : 78.29.3.119 addr : 78.29.3.122 addr : 78.29.3.124 addr : 78.29.3.3 addr : 78.29.3.4 addr : 78.29.3.7 addr : 78.29.3.9 addr : 78.29.3.10 addr : 78.29.3.11 addr : 78.29.3.12 addr : 78.29.3.13 addr : 78.29.3.14 addr : 78.29.3.16 addr : 78.29.3.18 addr : 78.29.3.19 addr : 78.29.3.21 addr : 78.29.3.27 addr : 78.29.3.33 addr : 78.29.3.35 addr : 78.29.3.37 addr : 78.29.3.41 addr : 78.29.3.42 addr : 78.29.3.44 addr : 78.29.3.45 addr : 78.29.3.46 addr : 78.29.3.47 total 30 addresses aliases: unlim.is74.ru $ ./xgcc.sh -Os -o gethostbyname gethostbyname.c /tmp/ccY6ZTg9.o: In function `main': gethostbyname.c:(.text+0x4c): warning: gethostbyname_r is obsolescent, use getnameinfo() instead. $ ./gethostbyname unlim.is74.ru name : unlim.is74.ru fam : 2 addrlen: 4 addr : 78.29.3.110 addr : 78.29.3.115 addr : 78.29.3.116 addr : 78.29.3.117 addr : 78.29.3.118 addr : 78.29.3.119 addr : 78.29.3.122 addr : 78.29.3.124 addr : 78.29.3.3 addr : 78.29.3.4 addr : 78.29.3.7 addr : 78.29.3.9 addr : 78.29.3.10 addr : 78.29.3.11 addr : 78.29.3.12 addr : 78.29.3.13 addr : 78.29.3.14 addr : 78.29.3.16 addr : 78.29.3.18 addr : 78.29.3.19 addr : 78.29.3.21 addr : 78.29.3.27 addr : 78.29.3.33 addr : 78.29.3.35 addr : 78.29.3.37 addr : 78.29.3.41 addr : 78.29.3.42 addr : 78.29.3.44 addr : 78.29.3.45 addr : 78.29.3.46 total 30 addresses aliases: unlim.is74.ru