From 5a4137eff4dec7d3e2d9de804847f63ba97289c7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 29 Jul 1998 21:32:28 +0000 Subject: Gunther Leber's fix. svn path=/trunk/; revision=2027 --- env.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/env.c b/env.c index 202b69e2..453e1449 100644 --- a/env.c +++ b/env.c @@ -62,6 +62,8 @@ void envquery(int argc, char **argv) exit(PS_IOERR); } #ifdef HAVE_GETHOSTBYNAME + /* if we got a . in the hostname assume it is a FQDN */ + if (strchr(tmpbuf, '.') == NULL) { struct hostent *hp; @@ -73,14 +75,20 @@ void envquery(int argc, char **argv) fprintf(stderr, "gethostbyname failed for %s\n", tmpbuf); exit(PS_DNS); } - strcpy(tmpbuf, hp->h_name); + fetchmailhost = xstrdup(hp->h_name); } + else #endif /* HAVE_GETHOSTBYNAME */ - fetchmailhost = xstrdup(tmpbuf); + fetchmailhost = xstrdup(tmpbuf); #define RCFILE_NAME ".fetchmailrc" rcfile = (char *) xmalloc(strlen(home)+strlen(RCFILE_NAME)+2); - strcpy(rcfile, home); + /* avoid //.fetchmailrc */ + if (strcmp(home, "/") != 0) { + strcpy(rcfile, home); + } else { + *rcfile = '\0'; + } strcat(rcfile, "/"); strcat(rcfile, RCFILE_NAME); } -- cgit v1.2.3