diff options
author | guenther <> | 2015-07-16 02:46:49 +0000 |
---|---|---|
committer | guenther <> | 2015-07-16 02:46:49 +0000 |
commit | a9d83bef026ef5bd117c61db209676f190f7980f (patch) | |
tree | a25a03512c658c1fd96660587edb8c54ec89a6c2 /src | |
parent | 0f36cbbfbb33554482f86b90bbe673c9c4f917a3 (diff) | |
download | openbsd-a9d83bef026ef5bd117c61db209676f190f7980f.tar.gz openbsd-a9d83bef026ef5bd117c61db209676f190f7980f.tar.bz2 openbsd-a9d83bef026ef5bd117c61db209676f190f7980f.zip |
After reading a password with terminal echo off, restore the terminal to
its original state instead of blindly turning echo on.
problem reported on the openssl-dev list by William Freeman
ok miod@ beck@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ui/ui_openssl.c | 11 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/ui/ui_openssl.c | 11 |
2 files changed, 10 insertions, 12 deletions
diff --git a/src/lib/libcrypto/ui/ui_openssl.c b/src/lib/libcrypto/ui/ui_openssl.c index a46534e3e5..b3d2971a02 100644 --- a/src/lib/libcrypto/ui/ui_openssl.c +++ b/src/lib/libcrypto/ui/ui_openssl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ui_openssl.c,v 1.23 2014/07/13 00:10:47 deraadt Exp $ */ | 1 | /* $OpenBSD: ui_openssl.c,v 1.24 2015/07/16 02:46:49 guenther Exp $ */ |
2 | /* Written by Richard Levitte (richard@levitte.org) and others | 2 | /* Written by Richard Levitte (richard@levitte.org) and others |
3 | * for the OpenSSL project 2001. | 3 | * for the OpenSSL project 2001. |
4 | */ | 4 | */ |
@@ -134,7 +134,7 @@ | |||
134 | /* Define globals. They are protected by a lock */ | 134 | /* Define globals. They are protected by a lock */ |
135 | static struct sigaction savsig[NX509_SIG]; | 135 | static struct sigaction savsig[NX509_SIG]; |
136 | 136 | ||
137 | static struct termios tty_orig, tty_new; | 137 | static struct termios tty_orig; |
138 | static FILE *tty_in, *tty_out; | 138 | static FILE *tty_in, *tty_out; |
139 | static int is_a_tty; | 139 | static int is_a_tty; |
140 | 140 | ||
@@ -325,7 +325,8 @@ open_console(UI *ui) | |||
325 | static int | 325 | static int |
326 | noecho_console(UI *ui) | 326 | noecho_console(UI *ui) |
327 | { | 327 | { |
328 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 328 | struct termios tty_new = tty_orig; |
329 | |||
329 | tty_new.c_lflag &= ~ECHO; | 330 | tty_new.c_lflag &= ~ECHO; |
330 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) | 331 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) |
331 | return 0; | 332 | return 0; |
@@ -335,9 +336,7 @@ noecho_console(UI *ui) | |||
335 | static int | 336 | static int |
336 | echo_console(UI *ui) | 337 | echo_console(UI *ui) |
337 | { | 338 | { |
338 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 339 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_orig) == -1)) |
339 | tty_new.c_lflag |= ECHO; | ||
340 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) | ||
341 | return 0; | 340 | return 0; |
342 | return 1; | 341 | return 1; |
343 | } | 342 | } |
diff --git a/src/lib/libssl/src/crypto/ui/ui_openssl.c b/src/lib/libssl/src/crypto/ui/ui_openssl.c index a46534e3e5..b3d2971a02 100644 --- a/src/lib/libssl/src/crypto/ui/ui_openssl.c +++ b/src/lib/libssl/src/crypto/ui/ui_openssl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ui_openssl.c,v 1.23 2014/07/13 00:10:47 deraadt Exp $ */ | 1 | /* $OpenBSD: ui_openssl.c,v 1.24 2015/07/16 02:46:49 guenther Exp $ */ |
2 | /* Written by Richard Levitte (richard@levitte.org) and others | 2 | /* Written by Richard Levitte (richard@levitte.org) and others |
3 | * for the OpenSSL project 2001. | 3 | * for the OpenSSL project 2001. |
4 | */ | 4 | */ |
@@ -134,7 +134,7 @@ | |||
134 | /* Define globals. They are protected by a lock */ | 134 | /* Define globals. They are protected by a lock */ |
135 | static struct sigaction savsig[NX509_SIG]; | 135 | static struct sigaction savsig[NX509_SIG]; |
136 | 136 | ||
137 | static struct termios tty_orig, tty_new; | 137 | static struct termios tty_orig; |
138 | static FILE *tty_in, *tty_out; | 138 | static FILE *tty_in, *tty_out; |
139 | static int is_a_tty; | 139 | static int is_a_tty; |
140 | 140 | ||
@@ -325,7 +325,8 @@ open_console(UI *ui) | |||
325 | static int | 325 | static int |
326 | noecho_console(UI *ui) | 326 | noecho_console(UI *ui) |
327 | { | 327 | { |
328 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 328 | struct termios tty_new = tty_orig; |
329 | |||
329 | tty_new.c_lflag &= ~ECHO; | 330 | tty_new.c_lflag &= ~ECHO; |
330 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) | 331 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) |
331 | return 0; | 332 | return 0; |
@@ -335,9 +336,7 @@ noecho_console(UI *ui) | |||
335 | static int | 336 | static int |
336 | echo_console(UI *ui) | 337 | echo_console(UI *ui) |
337 | { | 338 | { |
338 | memcpy(&(tty_new), &(tty_orig), sizeof(tty_orig)); | 339 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_orig) == -1)) |
339 | tty_new.c_lflag |= ECHO; | ||
340 | if (is_a_tty && (tcsetattr(fileno(tty_in), TCSANOW, &tty_new) == -1)) | ||
341 | return 0; | 340 | return 0; |
342 | return 1; | 341 | return 1; |
343 | } | 342 | } |