summaryrefslogtreecommitdiffstats
path: root/toolchain/uClibc/uClibc-0.9.29-fix-resolve-in-etc-hosts.patch
blob: a64bd4cda572522995db61e1c24237a2fb8253a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 91cb4bb00e4d9463c0d41015152daa4b39acf762 Mon Sep 17 00:00:00 2001
From: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Date: Tue, 18 Sep 2007 10:15:05 +0200
Subject: [PATCH] Fix resolve when identical IPv4 and IPv6 hosts are defined in /etc/hosts

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 <hcegtvedt@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);
-- 
1.5.2.5