error handling in rpc and transport functions

This commit is contained in:
Benoît LeBlanc 2013-12-20 17:56:59 -05:00
parent 20c677ddaa
commit 44e7d2f36c
4 changed files with 23 additions and 9 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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);