summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libutil/pw_util.c10
-rw-r--r--usr.sbin/vipw/pw_util.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
index 6283b95..21e0ca5 100644
--- a/lib/libutil/pw_util.c
+++ b/lib/libutil/pw_util.c
@@ -202,14 +202,14 @@ pw_edit(notsetuid)
void
pw_prompt()
{
- int c;
+ int c, first;
(void)printf("re-edit the password file? [y]: ");
(void)fflush(stdout);
- c = getchar();
- if (c != EOF && c != '\n')
- while (getchar() != '\n');
- if (c == 'n')
+ first = c = getchar();
+ while (c != '\n' && c != EOF)
+ c = getchar();
+ if (first == 'n')
pw_error(NULL, 0, 0);
}
diff --git a/usr.sbin/vipw/pw_util.c b/usr.sbin/vipw/pw_util.c
index 6283b95..21e0ca5 100644
--- a/usr.sbin/vipw/pw_util.c
+++ b/usr.sbin/vipw/pw_util.c
@@ -202,14 +202,14 @@ pw_edit(notsetuid)
void
pw_prompt()
{
- int c;
+ int c, first;
(void)printf("re-edit the password file? [y]: ");
(void)fflush(stdout);
- c = getchar();
- if (c != EOF && c != '\n')
- while (getchar() != '\n');
- if (c == 'n')
+ first = c = getchar();
+ while (c != '\n' && c != EOF)
+ c = getchar();
+ if (first == 'n')
pw_error(NULL, 0, 0);
}
OpenPOWER on IntegriCloud