diff --git a/libfreerdp/core/gateway/rpc.c b/libfreerdp/core/gateway/rpc.c index 5a3760f35..f58a3a55c 100644 --- a/libfreerdp/core/gateway/rpc.c +++ b/libfreerdp/core/gateway/rpc.c @@ -447,7 +447,9 @@ int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum) offset += Buffers[1].cbBuffer; free(Buffers[1].pvBuffer); - rpc_send_enqueue_pdu(rpc, buffer, request_pdu->frag_length); + if (rpc_send_enqueue_pdu(rpc, buffer, request_pdu->frag_length) != 0) + length = -1; + free(request_pdu); return length; diff --git a/libfreerdp/core/gateway/rpc_bind.c b/libfreerdp/core/gateway/rpc_bind.c index 108d7ff14..df33de191 100644 --- a/libfreerdp/core/gateway/rpc_bind.c +++ b/libfreerdp/core/gateway/rpc_bind.c @@ -215,7 +215,8 @@ int rpc_send_bind_pdu(rdpRpc* rpc) clientCall = rpc_client_call_new(bind_pdu->call_id, 0); ArrayList_Add(rpc->client->ClientCallList, clientCall); - rpc_send_enqueue_pdu(rpc, buffer, length); + if (rpc_send_enqueue_pdu(rpc, buffer, length) != 0) + length = -1; free(bind_pdu->p_context_elem.p_cont_elem[0].transfer_syntaxes); free(bind_pdu->p_context_elem.p_cont_elem[1].transfer_syntaxes); @@ -330,7 +331,8 @@ int rpc_send_rpc_auth_3_pdu(rdpRpc* rpc) clientCall = rpc_client_call_new(auth_3_pdu->call_id, 0); ArrayList_Add(rpc->client->ClientCallList, clientCall); - rpc_send_enqueue_pdu(rpc, buffer, length); + if (rpc_send_enqueue_pdu(rpc, buffer, length) != 0) + length = -1; free(auth_3_pdu); diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 567fc169e..aaab6d358 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -82,7 +82,7 @@ BOOL transport_disconnect(rdpTransport* transport) if ((transport->layer == TRANSPORT_LAYER_TSG) || (transport->layer == TRANSPORT_LAYER_TSG_TLS)) { - tsg_disconnect(transport->tsg); + status &= tsg_disconnect(transport->tsg); } else { @@ -129,12 +129,12 @@ static int transport_bio_tsg_write(BIO* bio, const char* buf, int num) BIO_clear_retry_flags(bio); - if (status <= 0) + if (status == 0) { BIO_set_retry_write(bio); } - return num; + return status < 0 ? 0 : num; } static int transport_bio_tsg_read(BIO* bio, char* buf, int size) @@ -147,12 +147,17 @@ static int transport_bio_tsg_read(BIO* bio, char* buf, int size) BIO_clear_retry_flags(bio); - if (status <= 0) + if (status == 0) { BIO_set_retry_read(bio); + status = -1; + } + else if (status == -1) + { + status = 0; } - return status > 0 ? status : -1; + return status >= 0 ? status : -1; } static int transport_bio_tsg_puts(BIO* bio, const char* str) diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index 4fe93ee94..6053a292a 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -464,7 +464,12 @@ int tls_write(rdpTls* tls, BYTE* data, int length) status = SSL_write(tls->ssl, data, length); - if (status <= 0) + if (status == 0) + { + return -1; /* peer disconnected */ + } + + if (status < 0) { error = SSL_get_error(tls->ssl, status);