X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=env.c;h=edf998983a88be540d639946ed9c8b669711f07f;hb=53293ee30678d3db753e51820cc554c0b2b1bd97;hp=f9a3bf9a15a0f1476198246c72fff492cc9c7dba;hpb=eef055db24af6968157b9d919613b4816c1815b7;p=~andy%2Ffetchmail diff --git a/env.c b/env.c index f9a3bf9a..edf99898 100644 --- a/env.c +++ b/env.c @@ -30,7 +30,9 @@ #include #endif +#ifndef HAVE_DECL_GETENV extern char *getenv(const char *); /* needed on sysV68 R3V7.1. */ +#endif void envquery(int argc, char **argv) /* set up basic stuff from the environment (including the rc file name) */ @@ -105,10 +107,12 @@ void envquery(int argc, char **argv) user = xstrdup(pwp->pw_name); } + endpwent(); + /* compute user's home directory */ home = getenv("HOME_ETC"); if (!home && !(home = getenv("HOME"))) - home = pwp->pw_dir; + home = xstrdup(pwp->pw_dir); /* compute fetchmail's home directory */ if (!(fmhome = getenv("FETCHMAILHOME"))) @@ -159,7 +163,7 @@ char *host_fqdn(int required) memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - hints.ai_flags=AI_CANONNAME; + hints.ai_flags = AI_CANONNAME; e = fm_getaddrinfo(tmpbuf, NULL, &hints, &res); if (e) { @@ -290,9 +294,9 @@ char *visbuf(const char *buf) needed = strlen(buf) * 5 + 1; /* worst case: HEX, plus NUL byte */ - if (needed > vbufs) { + if (!vbuf || needed > vbufs) { vbufs = needed; - vbuf = xrealloc(vbuf, vbufs); + vbuf = (char *)xrealloc(vbuf, vbufs); } tp = vbuf; @@ -318,7 +322,7 @@ char *visbuf(const char *buf) buf++; } } - *tp++ = '\0'; + *tp = '\0'; return(vbuf); } /* env.c ends here */