diff options
author | Matt Caswell <matt@openssl.org> | 2020-01-17 17:39:19 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2020-02-04 14:39:29 +0000 |
commit | d924dbf4ae127c68463bcbece04b6e06abc58928 (patch) | |
tree | 465bacfdfae92f28ee84ae47fba82f4fb044f2fa /crypto/bio/bss_sock.c | |
parent | 579422c85cf606c0ae1d4baf414010dc21da657a (diff) |
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: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10907)
Diffstat (limited to 'crypto/bio/bss_sock.c')
-rw-r--r-- | crypto/bio/bss_sock.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c index 09cc4e30a0..fd24bbc2bf 100644 --- a/crypto/bio/bss_sock.c +++ b/crypto/bio/bss_sock.c @@ -118,6 +118,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; @@ -210,6 +212,9 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr) ret = 0; break; # endif + case BIO_CTRL_EOF: + ret = (b->flags & BIO_FLAGS_IN_EOF) != 0 ? 1 : 0; + break; default: ret = 0; break; |