diff options
-rw-r--r-- | lib/libutil/passwd.c | 13 | ||||
-rw-r--r-- | usr.sbin/cron/crontab.c | 13 |
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index 2807b024520..ba7a0a52622 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.44 2004/07/13 21:09:48 millert Exp $ */ +/* $OpenBSD: passwd.c,v 1.45 2004/11/04 18:44:59 millert Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -30,7 +30,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$OpenBSD: passwd.c,v 1.44 2004/07/13 21:09:48 millert Exp $"; +static const char rcsid[] = "$OpenBSD: passwd.c,v 1.45 2004/11/04 18:44:59 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -275,8 +275,15 @@ pw_prompt(void) first = c = getchar(); while (c != '\n' && c != EOF) c = getchar(); - if (first == 'n') + switch (first) { + case EOF: + putchar('\n'); + /* FALLTHROUGH */ + case 'n': + case 'N': pw_error(NULL, 0, 0); + break; + } } static int diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 1d68908804e..cc44af45d25 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.46 2004/09/16 18:34:05 deraadt Exp $ */ +/* $OpenBSD: crontab.c,v 1.47 2004/11/04 18:44:59 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -22,7 +22,7 @@ */ #if !defined(lint) && !defined(LINT) -static char const rcsid[] = "$OpenBSD: crontab.c,v 1.46 2004/09/16 18:34:05 deraadt Exp $"; +static char const rcsid[] = "$OpenBSD: crontab.c,v 1.47 2004/11/04 18:44:59 millert Exp $"; #endif /* crontab - install and manage per-user crontab files @@ -461,7 +461,10 @@ edit_cmd(void) { printf("Do you want to retry the same edit? "); fflush(stdout); q[0] = '\0'; - (void) fgets(q, sizeof q, stdin); + if (fgets(q, sizeof q, stdin) == NULL) { + putchar('\n'); + goto abandon; + } switch (q[0]) { case 'y': case 'Y': @@ -508,8 +511,8 @@ replace_cmd(void) { fprintf(stderr, "%s: Cannot allocate memory.\n", ProgramName); return (-2); } - if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXXXXX", SPOOL_DIR) >= - sizeof(TempFilename)) { + if (snprintf(TempFilename, sizeof TempFilename, "%s/tmp.XXXXXXXXX", + SPOOL_DIR) >= sizeof(TempFilename)) { TempFilename[0] = '\0'; fprintf(stderr, "path too long\n"); return (-2); |