Fix socket fd leak and other changes

1. In connect_to_sshagent() if connect() fails, the socket agent_fd is
   leaked.  It needs to be closed before returning.

2. Fix copyright messages.

3. Make if statement with call to CreateThread() clearer to read.
This commit is contained in:
Ben Cohen 2017-09-08 16:52:14 +01:00
parent 0e90841a18
commit 7e262213ca
3 changed files with 11 additions and 7 deletions

View File

@ -2,6 +2,7 @@
# FreeRDP cmake build script
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 Ben Cohen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@ -2,6 +2,7 @@
# FreeRDP cmake build script
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
# Copyright 2012 Ben Cohen
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@ -115,6 +115,7 @@ static int connect_to_sshagent(const char *udspath)
{
WLog_ERR(TAG, "Can't connect to Unix domain socket \"%s\"!",
udspath);
close(agent_fd);
return -1;
}
@ -293,13 +294,14 @@ static UINT sshagent_on_new_channel_connection(IWTSListenerCallback* pListenerCa
callback->channel_mgr = listener_callback->channel_mgr;
callback->channel = pChannel;
if (!(callback->thread
= CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) sshagent_read_thread,
(void*) callback,
0,
NULL)))
callback->thread
= CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE) sshagent_read_thread,
(void*) callback,
0,
NULL);
if (!callback->thread)
{
WLog_ERR(TAG, "CreateThread failed!");
return CHANNEL_RC_INITIALIZATION_ERROR;