From: Ondrej Holy Date: Fri, 17 Aug 2018 14:00:19 +0000 (+0200) Subject: core/gateway/rpc: Fix leak found by covscan X-Git-Tag: 2.0.0-rc4~110^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=83e966d9e257276ecbfc311c0ff06bb5f3820036;p=platform%2Fupstream%2Ffreerdp.git core/gateway/rpc: Fix leak found by covscan 0 is valid return value from socket(). leaked_storage: Variable "auth_3_pdu" going out of scope leaks the storage it points to. leaked_storage: Variable "response" going out of scope leaks the storage it points to. leaked_handle: Handle variable "sockfd" going out of scope leaks the handle. --- diff --git a/libfreerdp/core/gateway/rpc.c b/libfreerdp/core/gateway/rpc.c index d01e309..3897817 100644 --- a/libfreerdp/core/gateway/rpc.c +++ b/libfreerdp/core/gateway/rpc.c @@ -740,7 +740,7 @@ static int rpc_channel_tls_connect(RpcChannel* channel, int timeout) sockfd = freerdp_tcp_connect(context, settings, peerHostname, peerPort, timeout); - if (sockfd < 1) + if (sockfd < 0) return -1; socketBio = BIO_new(BIO_s_simple_socket()); diff --git a/libfreerdp/core/gateway/rpc_bind.c b/libfreerdp/core/gateway/rpc_bind.c index 54fd322..81516d9 100644 --- a/libfreerdp/core/gateway/rpc_bind.c +++ b/libfreerdp/core/gateway/rpc_bind.c @@ -349,7 +349,10 @@ int rpc_send_rpc_auth_3_pdu(rdpRpc* rpc) buffer = (BYTE*) malloc(auth_3_pdu->frag_length); if (!buffer) + { + free(auth_3_pdu); return -1; + } CopyMemory(buffer, auth_3_pdu, 20); offset = 20; diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index 9bd1bcf..0bee974 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -476,6 +476,7 @@ static int rpc_client_default_out_channel_recv(rdpRpc* rpc) /* Receive OUT Channel Response */ if (rpc_ncacn_http_recv_out_channel_response(rpc, outChannel, response) < 0) { + http_response_free(response); WLog_ERR(TAG, "rpc_ncacn_http_recv_out_channel_response failure"); return -1; } @@ -484,6 +485,7 @@ static int rpc_client_default_out_channel_recv(rdpRpc* rpc) if (rpc_ncacn_http_send_out_channel_request(rpc, outChannel, FALSE) < 0) { + http_response_free(response); WLog_ERR(TAG, "rpc_ncacn_http_send_out_channel_request failure"); return -1; } @@ -496,6 +498,7 @@ static int rpc_client_default_out_channel_recv(rdpRpc* rpc) if (rts_send_CONN_A1_pdu(rpc) < 0) { + http_response_free(response); WLog_ERR(TAG, "rpc_send_CONN_A1_pdu error!"); return -1; }