From 7d48b483950f0e5403ed63e35f17da9e156e1950 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 26 Feb 2002 03:02:20 +0000 Subject: Thomas Fritzsche noticed that __open_etc_hosts was only changing a local copy of the FILE pointer, thereby causing /etc/hosts lookups to fail with Resolver errors. This patch from Thomas fixes the problem. --- libc/inet/resolv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'libc') diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index e785e47bd..1f464f37f 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -120,7 +120,7 @@ extern int searchdomains; 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 @@ struct hostent *gethostbyaddr (const void *addr, socklen_t len, int type) #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 @@ struct hostent * read_etc_hosts(FILE * fp, const char * name, int type, enum etc 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 *gethostent (void) 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); } -- cgit v1.2.3