summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-08-07 19:34:12 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-08-07 19:34:12 +0000
commitaed123bb7bc3b86f0aa45d5b600229cc174ef5f3 (patch)
tree44bbb7242d20655021f023f83b82eb0987faacf1 /lib/libc/gen
parent3a158cf75f63a6a0c391e33ca40774087c3dcf0a (diff)
Do the memset only if tcgetattr() fails just in case the failed
tcgetattr() mucked with the passed in struct termios in some way.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/readpassphrase.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c
index 2892f1f4ae4..7a77fb85d97 100644
--- a/lib/libc/gen/readpassphrase.c
+++ b/lib/libc/gen/readpassphrase.c
@@ -26,7 +26,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.6 2001/08/07 19:29:20 millert Exp $";
+static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.7 2001/08/07 19:34:11 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <ctype.h>
@@ -82,8 +82,6 @@ readpassphrase(prompt, buf, bufsiz, flags)
(void)sigprocmask(SIG_BLOCK, &nset, &oset);
/* Turn off echo if possible. */
- memset(&term, 0, sizeof(term));
- memset(&oterm, 0, sizeof(oterm));
if (tcgetattr(input, &oterm) == 0) {
memcpy(&term, &oterm, sizeof(term));
if (!(flags & RPP_ECHO_ON) && (term.c_lflag & ECHO))
@@ -91,6 +89,9 @@ readpassphrase(prompt, buf, bufsiz, flags)
if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
term.c_cc[VSTATUS] = _POSIX_VDISABLE;
(void)tcsetattr(input, TCSAFLUSH|TCSASOFT, &term);
+ } else {
+ memset(&term, 0, sizeof(term));
+ memset(&oterm, 0, sizeof(oterm));
}
(void)write(output, prompt, strlen(prompt));