[uClibc]bug in resolv.c

Thomas Fritzsche tf at noto.de
Mon Feb 25 19:29:19 UTC 2002


Hi folks,

I wrote today in and reported about a "Resolver error" with names in
/etc/hosts. Now I found the bug in resolv.c in the function
__open_etc_hosts().

I send a patch with this eMail. It's a patch for uClibc-0.9.9. But I
found the same problem in the daily-snapshot.

Could you insert the patch in the next version.

bye,
 Thomas Fritzsche


-------------- next part --------------
diff -urN uClibc-0.9.9/libc/inet/resolv.c uClibc-0.9.9.net/libc/inet/resolv.c
--- uClibc-0.9.9/libc/inet/resolv.c	Sat Feb  2 14:51:19 2002
+++ uClibc-0.9.9.net/libc/inet/resolv.c	Mon Feb 25 20:07:08 2002
@@ -120,7 +120,7 @@
 extern char * searchdomain[MAX_SEARCH];
 extern struct hostent * get_hosts_byname(const char * name, int type);
 extern struct hostent * get_hosts_byaddr(const char * addr, int len, int type);
-extern void __open_etc_hosts(FILE *fp);
+extern void __open_etc_hosts(FILE **fp);
 extern struct hostent * read_etc_hosts(FILE *fp, const char * name, int type, enum etc_hosts_action action);
 extern int resolve_address(const char * address, int nscount, 
 	char ** nsip, struct in_addr * in);
@@ -1327,10 +1327,10 @@
 
 #ifdef L_read_etc_hosts
 
-void __open_etc_hosts(FILE *fp)
+void __open_etc_hosts(FILE **fp)
 {
-	if ((fp = fopen("/etc/hosts", "r")) == NULL) {
-		fp = fopen("/etc/config/hosts", "r");
+	if ((*fp = fopen("/etc/hosts", "r")) == NULL) {
+		*fp = fopen("/etc/config/hosts", "r");
 	}
 	return;
 }
@@ -1351,7 +1351,7 @@
 	int						aliases, i;
 
 	if (action!=GETHOSTENT) {
-		__open_etc_hosts(fp);
+		__open_etc_hosts(&fp);
 		if (fp == NULL) {
 			return((struct hostent *)NULL);
 		}
@@ -1454,7 +1454,7 @@
     struct hostent *host;
 
     if (__gethostent_fp == NULL) {
-	__open_etc_hosts(__gethostent_fp);
+	__open_etc_hosts(&__gethostent_fp);
 	if (__gethostent_fp == NULL) {
 	    return((struct hostent *)NULL);
 	}


More information about the uClibc mailing list