[uClibc-cvs] CVS uClibc/libc/inet

CVS User andersen andersen at codepoet.org
Tue Jan 11 11:08:31 UTC 2005


Update of /var/cvs/uClibc/libc/inet
In directory nail:/tmp/cvs-serv15851/libc/inet

Modified Files:
	resolv.c 
Log Message:
Jan Lana writes:

uClibc resolver doesn't lookup all search domains.
For example, if you have computer 'jenda.prague.my.cz' and resolv.conf:
search my.cz
nameserver xx.xx.xx.xx

try this:
ping jenda.prague.my.cz         #works
ping jenda.prague               #unknown host

libc/inet/resolv.c doesn't want to try search domains if the domain name
contains '.'. I don't find any reason for the behaviour in literature
and it is inconsistent with the glibc.

Patch is attached.

regards,
- jenda



--- /var/cvs/uClibc/libc/inet/resolv.c	2004/09/07 10:34:35	1.58
+++ /var/cvs/uClibc/libc/inet/resolv.c	2005/01/11 11:08:30	1.59
@@ -672,7 +672,7 @@
 	int retries = 0;
 	unsigned char * packet = malloc(PACKETSZ);
 	char *dns, *lookup = malloc(MAXDNAME);
-	int variant = 0;
+	int variant = -1;
 	struct sockaddr_in sa;
 #ifdef __UCLIBC_HAS_IPV6__
 	int v6;
@@ -716,13 +716,14 @@
 			goto fail;
 
 		strncpy(lookup,name,MAXDNAME);
-		BIGLOCK;
-		if (variant < __searchdomains && strchr(lookup, '.') == NULL)
-		{
-		    strncat(lookup,".", MAXDNAME);
-		    strncat(lookup,__searchdomain[variant], MAXDNAME);
-		}
-		BIGUNLOCK;
+		if (variant >= 0) {
+                        BIGLOCK;
+                        if (variant < __searchdomains) {
+                                strncat(lookup,".", MAXDNAME);
+                                strncat(lookup,__searchdomain[variant], MAXDNAME);
+                        }
+                        BIGUNLOCK;
+                }
 		DPRINTF("lookup name: %s\n", lookup);
 		q.dotted = (char *)lookup;
 		q.qtype = type;
@@ -866,7 +867,7 @@
 		/* if there are other nameservers, give them a go,
 		   otherwise return with error */
 		{
-		    variant = 0;
+		    variant = -1;
                     LOCK;
                     ns = (ns + 1) % nscount;
                     if (ns == 0)
@@ -884,7 +885,7 @@
 		    sdomains=__searchdomains;
 		    BIGUNLOCK;
 
-		    if (variant < ((sdomains - 1) && strchr(lookup, '.') == NULL)) {
+		    if (variant < sdomains - 1) {
 			/* next search */
 			variant++;
 		    } else {
@@ -895,7 +896,7 @@
                           retries++;
 
 			UNLOCK;
-			variant = 0;
+			variant = -1;
 		    }
 		}
 	}



More information about the uClibc-cvs mailing list