From db943f43a60d1b5b1277e4b5317e8f288e7a0a3a Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 17 Jan 2020 17:39:19 +0000 Subject: Detect EOF while reading in libssl If we hit an EOF while reading in libssl then we will report an error back to the application (SSL_ERROR_SYSCALL) but errno will be 0. We add an error to the stack (which means we instead return SSL_ERROR_SSL) and therefore give a hint as to what went wrong. Contains a partial fix for #10880 Reviewed-by: Tomas Mraz Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/10882) --- crypto/bio/bss_sock.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crypto/bio') diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c index da818ca90e..3ad989adf2 100644 --- a/crypto/bio/bss_sock.c +++ b/crypto/bio/bss_sock.c @@ -101,6 +101,8 @@ static int sock_read(BIO *b, char *out, int outl) if (ret <= 0) { if (BIO_sock_should_retry(ret)) BIO_set_retry_read(b); + else if (ret == 0) + b->flags |= BIO_FLAGS_IN_EOF; } } return ret; @@ -151,6 +153,9 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_FLUSH: ret = 1; break; + case BIO_CTRL_EOF: + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + break; default: ret = 0; break; -- cgit v1.2.3