[PATCH] Fix resolve when identical IPv4 and IPv6 hosts are defined in /etc/hosts
Hans-Christian Egtvedt
hcegtvedt at atmel.com
Wed Sep 26 07:36:55 PDT 2007
On Tue, 2007-09-18 at 10:44 +0200, Hans-Christian Egtvedt wrote:
> This patch will fix a problem when the same host is defined with both IPv4 and
> IPv6 entries in /etc/hosts. Previous only the first of these host would work,
> as uClibc would read the /etc/hosts file from top to bottom, failing if the
> first hit did not match the IP type.
>
> Now uClibc will continue reading, even if the first correct entry name, but wrong IP
> type fails. Thus, allowing a second correct entry name with correct IP type
> will result in a name resolve.
Bump
Are there any comments to this patch?
> Signed-off-by: Hans-Christian Egtvedt <hcegtvedt at atmel.com>
> ---
> libc/inet/resolv.c | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
> index f4e6cac..9cdc3fe 100644
> --- a/libc/inet/resolv.c
> +++ b/libc/inet/resolv.c
> @@ -1643,7 +1643,7 @@ int attribute_hidden __read_etc_hosts_r(FILE * fp, const char * name, int type,
> *result=result_buf;
> ret=NETDB_SUCCESS;
> #ifdef __UCLIBC_HAS_IPV6__
> - } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
> + } else if (type == AF_INET6 && inet_pton(AF_INET6, alias[0], in6) > 0) {
> DPRINTF("Found INET6\n");
> addr_list6[0] = in6;
> addr_list6[1] = 0;
> @@ -1658,8 +1658,8 @@ int attribute_hidden __read_etc_hosts_r(FILE * fp, const char * name, int type,
> } else {
> DPRINTF("Error\n");
> ret=TRY_AGAIN;
> - break; /* bad ip address */
> - }
> + continue; /* bad ip address, keep searching */
> + }
>
> if (action!=GETHOSTENT) {
> fclose(fp);
--
With kind regards,
Hans-Christian Egtvedt, Applications Engineer
More information about the uClibc
mailing list