From eb9184a174a8fb2f98f2f1418f87863716a5c115 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 2 Aug 2000 04:10:51 +0000 Subject: $HOME paranoia: never use getenv("HOME") w/o checking for NULL and non-zero --- usr.bin/mail/temp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'usr.bin/mail/temp.c') 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"); } -- cgit v1.2.3