diff options
author | Matt Caswell <matt@openssl.org> | 2020-01-17 17:39:19 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2020-02-20 17:02:30 +0000 |
commit | db943f43a60d1b5b1277e4b5317e8f288e7a0a3a (patch) | |
tree | 3c1d49da92ec78d523eb16b39ec1f51cd79e4905 /crypto | |
parent | b22a4996f38883e8376470597fef15a24cd8f535 (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: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/10882)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bio/bss_sock.c | 5 | ||||
-rw-r--r-- | crypto/err/openssl.txt | 1 |
2 files changed, 6 insertions, 0 deletions
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; diff --git a/crypto/err/openssl.txt b/crypto/err/openssl.txt index f4a14ccb82..10444a17f9 100644 --- a/crypto/err/openssl.txt +++ b/crypto/err/openssl.txt @@ -2851,6 +2851,7 @@ SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES:242:unable to load ssl3 md5 routines SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES:243:unable to load ssl3 sha1 routines SSL_R_UNEXPECTED_CCS_MESSAGE:262:unexpected ccs message SSL_R_UNEXPECTED_END_OF_EARLY_DATA:178:unexpected end of early data +SSL_R_UNEXPECTED_EOF_WHILE_READING:294:unexpected eof while reading SSL_R_UNEXPECTED_MESSAGE:244:unexpected message SSL_R_UNEXPECTED_RECORD:245:unexpected record SSL_R_UNINITIALIZED:276:uninitialized |