diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-11-04 18:45:00 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-11-04 18:45:00 +0000 |
commit | 10ef9812b94b6ca4ad8539ed42d5bcf4da2f6420 (patch) | |
tree | 60d59ec8d0b5b96b7c21332e7ed870b811c81b55 /lib | |
parent | a0ec2aca87629c67e7dea566970ddf0e7ae00f11 (diff) |
Treat EOF at prompt the same as 'n' instead of looping forever.
Noticed by mepch@. OK pedro@ and deraadt@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libutil/passwd.c | 13 |
1 files changed, 10 insertions, 3 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 |