summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-02-26 03:02:20 +0000
committerEric Andersen <andersen@codepoet.org>2002-02-26 03:02:20 +0000
commit7d48b483950f0e5403ed63e35f17da9e156e1950 (patch)
tree9ae8843a6036068d845b1fa9cf697ef1dbdd63a9
parent6793e73e905d85566c87a667f360c6fa3bd2bee0 (diff)
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.
-rw-r--r--libc/inet/resolv.c12
1 files changed, 6 insertions, 6 deletions
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);
}