[glib-networking/mcatanzaro/#20: 17/18] openssl: account for internal TLS buffer in check function
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/#20: 17/18] openssl: account for internal TLS buffer in check function
- Date: Tue, 1 Sep 2020 18:24:32 +0000 (UTC)
commit da11dc8ad9b11b9d3385451fc2eb9fcf3ad5890b
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Tue Aug 25 17:47:48 2020 -0500
openssl: account for internal TLS buffer in check function
This fixes the same bug as was reported for GnuTLS in #20.
tls/base/gtlsconnection-base.c | 3 +--
tls/openssl/gtlsconnection-openssl.c | 14 ++++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index e184552d..49c35590 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -924,8 +924,7 @@ g_tls_connection_base_check (GTlsConnectionBase *tls,
/* If base class says we are ready, then we are, regardless of the base
* stream status. This accounts for TLS-level buffers.
*/
- if (G_TLS_CONNECTION_BASE_GET_CLASS (tls)->check &&
- G_TLS_CONNECTION_BASE_GET_CLASS (tls)->check (tls, condition))
+ if (G_TLS_CONNECTION_BASE_GET_CLASS (tls)->check (tls, condition))
{
ret = TRUE;
goto out;
diff --git a/tls/openssl/gtlsconnection-openssl.c b/tls/openssl/gtlsconnection-openssl.c
index cc405a8e..13bf1a56 100644
--- a/tls/openssl/gtlsconnection-openssl.c
+++ b/tls/openssl/gtlsconnection-openssl.c
@@ -551,6 +551,19 @@ g_tls_connection_openssl_pop_io (GTlsConnectionBase *tls,
success, error);
}
+static gboolean
+g_tls_connection_openssl_check (GTlsConnectionBase *tls,
+ GIOCondition direction)
+{
+ GTlsConnectionOpenssl *openssl = G_TLS_CONNECTION_OPENSSL (tls);
+ SSL *ssl = g_tls_connection_openssl_get_ssl (openssl);
+
+ if (direction & G_IO_IN)
+ return SSL_has_pending (ssl);
+
+ return FALSE;
+}
+
static GTlsConnectionBaseStatus
g_tls_connection_openssl_read (GTlsConnectionBase *tls,
void *buffer,
@@ -687,6 +700,7 @@ g_tls_connection_openssl_class_init (GTlsConnectionOpensslClass *klass)
base_class->retrieve_peer_certificate =
g_tls_connection_openssl_retrieve_peer_certificate;
base_class->push_io = g_tls_connection_openssl_push_io;
base_class->pop_io = g_tls_connection_openssl_pop_io;
+ base_class->check = g_tls_connection_openssl_check;
base_class->read_fn = g_tls_connection_openssl_read;
base_class->write_fn = g_tls_connection_openssl_write;
base_class->close_fn = g_tls_connection_openssl_close;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]