summaryrefslogtreecommitdiff
path: root/usr.bin/at
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-01-21 04:22:55 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-01-21 04:22:55 +0000
commitd5c06a7b79c8c3d1cc30653cb9fa495116058175 (patch)
treec65758bd12bbfb7d88470c203330e1f42857526a /usr.bin/at
parent872761ead8d922e6e701e299640b53254f57cea5 (diff)
Deal with getcwd() returning NULL.
Problem noted by Oleg Safiullin <form@vell.nsc.ru>
Diffstat (limited to 'usr.bin/at')
-rw-r--r--usr.bin/at/at.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c
index 1ddab472b20..6733657e3a3 100644
--- a/usr.bin/at/at.c
+++ b/usr.bin/at/at.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: at.c,v 1.17 1999/12/15 05:33:06 deraadt Exp $ */
+/* $OpenBSD: at.c,v 1.18 2000/01/21 04:22:54 millert Exp $ */
/* $NetBSD: at.c,v 1.4 1995/03/25 18:13:31 glass Exp $ */
/*
@@ -74,7 +74,7 @@ enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */
/* File scope variables */
#ifndef lint
-static char rcsid[] = "$OpenBSD: at.c,v 1.17 1999/12/15 05:33:06 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: at.c,v 1.18 2000/01/21 04:22:54 millert Exp $";
#endif
char *no_export[] =
@@ -280,8 +280,8 @@ writefile(runtimer, queue)
panic("Cannot reopen atjob file");
/*
- * Get the userid to mail to, first by trying getlogin(), which reads
- * /etc/utmp, then from $LOGNAME or $USER, finally from getpwuid().
+ * Get the userid to mail to, first by trying getlogin(), which asks
+ * the kernel, then from $LOGNAME or $USER, finally from getpwuid().
*/
mailname = getlogin();
if (mailname == NULL && (mailname = getenv("LOGNAME")) == NULL)
@@ -361,8 +361,10 @@ writefile(runtimer, queue)
* Cd to the directory at the time and write out all the
* commands the user supplies from stdin.
*/
+ if ((ap = cwdname()) == NULL)
+ perr("Cannot get current working directory");
(void)fputs("cd ", fp);
- for (ap = cwdname(); *ap != '\0'; ap++) {
+ for (; *ap != '\0'; ap++) {
if (*ap == '\n')
fprintf(fp, "\"\n\"");
else {