summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGonzalo Aguilar Delgado <gaguilar@level2crm.com>2017-05-25 18:15:30 +0200
committerJames E. King, III <jking@apache.org>2017-09-21 09:09:20 -0700
commitac61a4211204ec2785362fc325b500d805ae2bba (patch)
tree3838617863c661018a22249ccbf9f8348e134a40 /lib
parentacbb616192381674c32b3d4ebb2abf4942e4416a (diff)
downloadthrift-ac61a4211204ec2785362fc325b500d805ae2bba.tar.gz
THRIFT-4212: Fix flush on invalid socket
Client: c_glib This closes #1279
Diffstat (limited to 'lib')
-rw-r--r--lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c
index bc75e2c21..4abeb9341 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_ssl_socket.c
@@ -215,7 +215,10 @@ thrift_ssl_socket_read (ThriftTransport *transport, gpointer buf,
ThriftSSLSocket *ssl_socket = THRIFT_SSL_SOCKET (transport);
guint bytes = 0;
guint retries = 0;
- for (retries=0; retries < maxRecvRetries_; retries++) {
+ ThriftSocket *socket = THRIFT_SOCKET (transport);
+ g_return_val_if_fail (socket->sd != THRIFT_INVALID_SOCKET, FALSE);
+
+ for (retries=0; retries < maxRecvRetries_; retries++) {
bytes = SSL_read(ssl_socket->ssl, buf, len);
if (bytes >= 0)
break;
@@ -252,7 +255,7 @@ thrift_ssl_socket_write (ThriftTransport *transport, const gpointer buf,
ThriftSSLSocket *ssl_socket = THRIFT_SSL_SOCKET (transport);
gint ret = 0;
guint sent = 0;
- ThriftSocket *socket = THRIFT_SSL_SOCKET (transport);
+ ThriftSocket *socket = THRIFT_SOCKET (transport);
g_return_val_if_fail (socket->sd != THRIFT_INVALID_SOCKET, FALSE);
while (sent < len)
@@ -290,6 +293,10 @@ thrift_ssl_socket_flush (ThriftTransport *transport, GError **error)
ThriftSSLSocket *ssl_socket = THRIFT_SSL_SOCKET (transport);
gint ret = 0;
guint sent = 0;
+
+ ThriftSocket *socket = THRIFT_SOCKET (transport);
+ g_return_val_if_fail (socket->sd != THRIFT_INVALID_SOCKET, FALSE);
+
BIO* bio = SSL_get_wbio(ssl_socket->ssl);
if (bio == NULL) {
g_set_error (error, THRIFT_TRANSPORT_ERROR,