Fix an outstanding debian bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=658539
ok? -lum Index: fileio.c =================================================================== RCS file: /cvs/src/usr.bin/mg/fileio.c,v retrieving revision 1.93 diff -u -p -r1.93 fileio.c --- fileio.c 18 Jun 2012 07:14:55 -0000 1.93 +++ fileio.c 3 Jul 2012 11:24:06 -0000 @@ -701,7 +701,8 @@ expandtilde(const char *fn) struct passwd *pw; struct stat statbuf; const char *cp; - char user[LOGIN_NAME_MAX], path[NFILEN], *ret; + char user[LOGIN_NAME_MAX], path[NFILEN]; + char *ret, *un; size_t ulen, plen; path[0] = '\0'; @@ -720,9 +721,12 @@ expandtilde(const char *fn) return (NULL); return(ret); } - if (ulen == 0) /* ~/ or ~ */ - (void)strlcpy(user, getlogin(), sizeof(user)); - else { /* ~user/ or ~user */ + if (ulen == 0) { /* ~/ or ~ */ + if ((un = getlogin()) != NULL) + (void)strlcpy(user, un, sizeof(user)); + else + user[0] = '\0'; + } else { /* ~user/ or ~user */ memcpy(user, &fn[1], ulen); user[ulen] = '\0'; }