From 9688e1dfd0a77a6aa72326ee207ea1265bc91768 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 22 Jan 2020 06:40:42 +0000 Subject: Simplify the peekaboo code. ok beck@ --- src/usr.bin/openssl/s_client.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) (limited to 'src/usr.bin/openssl/s_client.c') diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c index 2cb9e26b59..b86f42e00d 100644 --- a/src/usr.bin/openssl/s_client.c +++ b/src/usr.bin/openssl/s_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_client.c,v 1.39 2020/01/22 04:51:48 beck Exp $ */ +/* $OpenBSD: s_client.c,v 1.40 2020/01/22 06:40:42 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1122,48 +1122,19 @@ re_start: } #endif if (peekaboo) { - p = SSL_peek(con, pbuf, 1024 /* BUFSIZZ */ ); - - switch (SSL_get_error(con, k)) { - case SSL_ERROR_NONE: + k = p = SSL_peek(con, pbuf, 1024 /* BUFSIZZ */ ); + if (SSL_get_error(con, p) == SSL_ERROR_NONE) { if (p <= 0) goto end; pbuf_off = 0; pbuf_len = p; - break; - case SSL_ERROR_WANT_WRITE: - BIO_printf(bio_c_out, "peek W BLOCK\n"); - write_ssl = 1; - read_tty = 0; - break; - case SSL_ERROR_WANT_READ: - BIO_printf(bio_c_out, "peek R BLOCK\n"); - write_tty = 0; - read_ssl = 1; - if ((read_tty == 0) && (write_ssl == 0)) - write_ssl = 1; - break; - case SSL_ERROR_WANT_X509_LOOKUP: - BIO_printf(bio_c_out, "peek X BLOCK\n"); - break; - case SSL_ERROR_SYSCALL: - ret = errno; - BIO_printf(bio_err, "peek:errno=%d\n", ret); - goto shut; - case SSL_ERROR_ZERO_RETURN: - BIO_printf(bio_c_out, "peek closed\n"); - ret = 0; - goto shut; - case SSL_ERROR_SSL: - ERR_print_errors(bio_err); - goto shut; - /* break; */ + k = SSL_read(con, sbuf, p); } + } else { + k = SSL_read(con, sbuf, 1024 /* BUFSIZZ */ ); } - k = SSL_read(con, sbuf, 1024 /* BUFSIZZ */ ); - switch (SSL_get_error(con, k)) { case SSL_ERROR_NONE: if (k <= 0) -- cgit v1.2.3-55-g6feb