aboutsummaryrefslogtreecommitdiffstats
path: root/env.c
diff options
context:
space:
mode:
Diffstat (limited to 'env.c')
-rw-r--r--env.c14
1 files 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);
}