Fixed misinterpretation of SendChannelData

SendChannelData was defined with a return value of type int, but
used as BOOL everywhere. Fix the definition to match use.
This commit is contained in:
Armin Novak 2020-03-09 10:33:58 +01:00 committed by akallabeth
parent c7187928e9
commit d5b5088eac
7 changed files with 23 additions and 36 deletions

View File

@ -176,8 +176,8 @@ extern "C"
typedef int (*pLogonErrorInfo)(freerdp* instance, UINT32 data, UINT32 type);
typedef int (*pSendChannelData)(freerdp* instance, UINT16 channelId, const BYTE* data,
int size);
typedef BOOL (*pSendChannelData)(freerdp* instance, UINT16 channelId, const BYTE* data,
size_t size);
typedef int (*pReceiveChannelData)(freerdp* instance, UINT16 channelId, BYTE* data, int size,
int flags, int totalSize);

View File

@ -51,8 +51,8 @@ typedef BOOL (*psPeerLogon)(freerdp_peer* peer, SEC_WINNT_AUTH_IDENTITY* identit
typedef BOOL (*psPeerAdjustMonitorsLayout)(freerdp_peer* peer);
typedef BOOL (*psPeerClientCapabilities)(freerdp_peer* peer);
typedef int (*psPeerSendChannelData)(freerdp_peer* peer, UINT16 channelId, const BYTE* data,
int size);
typedef BOOL (*psPeerSendChannelData)(freerdp_peer* peer, UINT16 channelId, const BYTE* data,
size_t size);
typedef int (*psPeerReceiveChannelData)(freerdp_peer* peer, UINT16 channelId, const BYTE* data,
size_t size, UINT32 flags, size_t totalSize);

View File

@ -488,18 +488,10 @@ int freerdp_message_queue_process_pending_messages(freerdp* instance, DWORD id)
return status;
}
static int freerdp_send_channel_data(freerdp* instance, UINT16 channelId, const BYTE* data,
int size)
static BOOL freerdp_send_channel_data(freerdp* instance, UINT16 channelId, const BYTE* data,
size_t size)
{
if (size < 0)
{
WLog_ERR(TAG, "%s: size has invalid value %d", __FUNCTION__, size);
return -1;
}
if (!rdp_send_channel_data(instance->context->rdp, channelId, data, (size_t)size))
return -2;
return 0;
return rdp_send_channel_data(instance->context->rdp, channelId, data, size);
}
BOOL freerdp_disconnect(freerdp* instance)
@ -1008,7 +1000,7 @@ const char* freerdp_get_logon_error_info_data(UINT32 data)
/** Allocator function for the rdp_freerdp structure.
* @return an allocated structure filled with 0s. Need to be deallocated using freerdp_free()
*/
freerdp* freerdp_new()
freerdp* freerdp_new(void)
{
freerdp* instance;
instance = (freerdp*)calloc(1, sizeof(freerdp));

View File

@ -736,17 +736,10 @@ static void freerdp_peer_disconnect(freerdp_peer* client)
transport_disconnect(transport);
}
static int freerdp_peer_send_channel_data(freerdp_peer* client, UINT16 channelId, const BYTE* data,
int size)
static BOOL freerdp_peer_send_channel_data(freerdp_peer* client, UINT16 channelId, const BYTE* data,
size_t size)
{
if (size < 0)
{
WLog_ERR(TAG, "%s: invalid size %d", __FUNCTION__, size);
return -1;
}
if (!rdp_send_channel_data(client->context->rdp, channelId, data, (size_t)size))
return -1;
return 0;
return rdp_send_channel_data(client->context->rdp, channelId, data, size);
}
static BOOL freerdp_peer_is_write_blocked(freerdp_peer* peer)

View File

@ -478,7 +478,6 @@ BOOL WTSVirtualChannelManagerCheckFileDescriptor(HANDLE hServer)
while (MessageQueue_Peek(vcm->queue, &message, TRUE))
{
int rc;
BYTE* buffer;
UINT32 length;
UINT16 channelId;
@ -486,8 +485,7 @@ BOOL WTSVirtualChannelManagerCheckFileDescriptor(HANDLE hServer)
buffer = (BYTE*)message.wParam;
length = (UINT32)(UINT_PTR)message.lParam;
rc = vcm->client->SendChannelData(vcm->client, channelId, buffer, length);
if (rc < 0)
if (!vcm->client->SendChannelData(vcm->client, channelId, buffer, length))
{
status = FALSE;
}

View File

@ -197,8 +197,8 @@ static BOOL pf_client_pre_connect(freerdp* instance)
return TRUE;
}
static BOOL pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channelId, BYTE* data,
int size, int flags, int totalSize)
static int pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channelId, BYTE* data,
int size, int flags, int totalSize)
{
pClientContext* pc = (pClientContext*)instance->context;
pServerContext* ps = pc->pdata->ps;
@ -221,11 +221,13 @@ static BOOL pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channe
ev.data_len = size;
if (!pf_modules_run_filter(FILTER_TYPE_CLIENT_PASSTHROUGH_CHANNEL_DATA, pdata, &ev))
return FALSE;
return -1;
server_channel_id = (UINT64)HashTable_GetItemValue(ps->vc_ids, (void*)channel_name);
return ps->context.peer->SendChannelData(ps->context.peer, (UINT16)server_channel_id,
data, size);
if (!ps->context.peer->SendChannelData(ps->context.peer, (UINT16)server_channel_id,
data, size))
return -1;
return 0;
}
}

View File

@ -226,8 +226,10 @@ static int pf_server_receive_channel_data_hook(freerdp_peer* peer, UINT16 channe
client_channel_id = (UINT64)HashTable_GetItemValue(pc->vc_ids, (void*)channel_name);
return pc->context.instance->SendChannelData(
pc->context.instance, (UINT16)client_channel_id, (BYTE*)data, size);
if (!pc->context.instance->SendChannelData(
pc->context.instance, (UINT16)client_channel_id, (BYTE*)data, size))
return -1;
return 0;
}
}