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.

Signed-off-by: Hans-Christian Egtvedt <[EMAIL PROTECTED]>
---
 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);
-- 
1.5.2.5

_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to