提交 a3ef2c16 编写于 作者: J John Denker 提交者: Rich Salz

RT2759: Don't read TTY when already at EOF.

Reviewed-by: NAndy Polyakov <appro@openssl.org>
上级 7315ce80
...@@ -818,6 +818,7 @@ int s_client_main(int argc, char **argv) ...@@ -818,6 +818,7 @@ int s_client_main(int argc, char **argv)
int socket_family = AF_UNSPEC, socket_type = SOCK_STREAM; int socket_family = AF_UNSPEC, socket_type = SOCK_STREAM;
int starttls_proto = PROTO_OFF, crl_format = FORMAT_PEM, crl_download = 0; int starttls_proto = PROTO_OFF, crl_format = FORMAT_PEM, crl_download = 0;
int write_tty, read_tty, write_ssl, read_ssl, tty_on, ssl_pending; int write_tty, read_tty, write_ssl, read_ssl, tty_on, ssl_pending;
int at_eof = 0;
int read_buf_len = 0; int read_buf_len = 0;
int fallback_scsv = 0; int fallback_scsv = 0;
long randamt = 0; long randamt = 0;
...@@ -2123,7 +2124,12 @@ int s_client_main(int argc, char **argv) ...@@ -2123,7 +2124,12 @@ int s_client_main(int argc, char **argv)
if (!ssl_pending) { if (!ssl_pending) {
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) #if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
if (tty_on) { if (tty_on) {
if (read_tty) /*
* Note that select() returns when read _would not block_,
* and EOF satisfies that. To avoid a CPU-hogging loop,
* set the flag so we exit.
*/
if (read_tty && !at_eof)
openssl_fdset(fileno(stdin), &readfds); openssl_fdset(fileno(stdin), &readfds);
if (write_tty) if (write_tty)
openssl_fdset(fileno(stdout), &writefds); openssl_fdset(fileno(stdout), &writefds);
...@@ -2369,6 +2375,9 @@ int s_client_main(int argc, char **argv) ...@@ -2369,6 +2375,9 @@ int s_client_main(int argc, char **argv)
} else } else
i = raw_read_stdin(cbuf, BUFSIZZ); i = raw_read_stdin(cbuf, BUFSIZZ);
if (i == 0)
at_eof = 1;
if ((!c_ign_eof) && ((i <= 0) || (cbuf[0] == 'Q' && cmdletters))) { if ((!c_ign_eof) && ((i <= 0) || (cbuf[0] == 'Q' && cmdletters))) {
BIO_printf(bio_err, "DONE\n"); BIO_printf(bio_err, "DONE\n");
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册