diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-08-02 04:10:51 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-08-02 04:10:51 +0000 |
commit | eb9184a174a8fb2f98f2f1418f87863716a5c115 (patch) | |
tree | 02b606fefe2b41782be054be7fdd586e53befba0 /usr.bin/mail/temp.c | |
parent | 3602a750205b32f442e2e132baa5b3e9a3c83349 (diff) |
$HOME paranoia: never use getenv("HOME") w/o checking for NULL and non-zero
Diffstat (limited to 'usr.bin/mail/temp.c')
-rw-r--r-- | usr.bin/mail/temp.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/mail/temp.c b/usr.bin/mail/temp.c index 9bff6c7b05b..350107cbf37 100644 --- a/usr.bin/mail/temp.c +++ b/usr.bin/mail/temp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: temp.c,v 1.10 1997/11/14 00:23:59 millert Exp $ */ +/* $OpenBSD: temp.c,v 1.11 2000/08/02 04:10:48 millert Exp $ */ /* $NetBSD: temp.c,v 1.5 1996/06/08 19:48:42 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)temp.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: temp.c,v 1.10 1997/11/14 00:23:59 millert Exp $"; +static char rcsid[] = "$OpenBSD: temp.c,v 1.11 2000/08/02 04:10:48 millert Exp $"; #endif #endif /* not lint */ @@ -85,9 +85,12 @@ tinit() } else myname = savestr(cp); } - if ((cp = getenv("HOME")) == NULL || strlen(getenv("HOME")) >= PATHSIZE) - cp = "."; - homedir = savestr(cp); + if ((cp = getenv("HOME")) == NULL || *cp == '\0' || + strlen(cp) >= PATHSIZE) + homedir = NULL; + else + homedir = savestr(cp); if (debug) - printf("user = %s, homedir = %s\n", myname, homedir); + printf("user = %s, homedir = %s\n", myname, + homedir ? homedir : "NONE"); } |