summaryrefslogtreecommitdiff
path: root/usr.bin/calendar/io.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-08-02 04:10:51 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-08-02 04:10:51 +0000
commiteb9184a174a8fb2f98f2f1418f87863716a5c115 (patch)
tree02b606fefe2b41782be054be7fdd586e53befba0 /usr.bin/calendar/io.c
parent3602a750205b32f442e2e132baa5b3e9a3c83349 (diff)
$HOME paranoia: never use getenv("HOME") w/o checking for NULL and non-zero
Diffstat (limited to 'usr.bin/calendar/io.c')
-rw-r--r--usr.bin/calendar/io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 9b4bfb06198..1b39f96a968 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.8 1999/11/25 03:46:47 pjanzen Exp $ */
+/* $OpenBSD: io.c,v 1.9 2000/08/02 04:10:47 millert Exp $ */
/*
* Copyright (c) 1989, 1993, 1994
@@ -43,7 +43,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
#else
-static char rcsid[] = "$OpenBSD: io.c,v 1.8 1999/11/25 03:46:47 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.9 2000/08/02 04:10:47 millert Exp $";
#endif
#endif /* not lint */
@@ -310,7 +310,10 @@ opencal()
if (!freopen(calendarFile, "r", stdin))
return (NULL);
} else {
- chdir(getenv("HOME"));
+ char *home = getenv("HOME");
+ if (home == NULL || *home == '\0')
+ errx(1, "cannot get home directory");
+ chdir(home);
if (!(chdir(calendarHome) == 0 &&
freopen(calendarFile, "r", stdin)))
errx(1, "no calendar file: ``%s'' or ``~/%s/%s",