]> Pileus Git - ~andy/fetchmail/blobdiff - env.c
Minor bug fixes for socket.c
[~andy/fetchmail] / env.c
diff --git a/env.c b/env.c
index eabc2f41e8baf36294b6dd6d8db5cc8d3906bb8a..edf998983a88be540d639946ed9c8b669711f07f 100644 (file)
--- a/env.c
+++ b/env.c
@@ -30,7 +30,9 @@
 #include <locale.h>
 #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,6 +107,8 @@ 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")))
@@ -290,7 +294,7 @@ 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 = (char *)xrealloc(vbuf, vbufs);
     }
@@ -318,7 +322,7 @@ char *visbuf(const char *buf)
            buf++;
        }
     }
-    *tp++ = '\0';
+    *tp = '\0';
     return(vbuf);
 }
 /* env.c ends here */