Fix #5852: handle CHANNEL_EVENT_WRITE_CANCELLED

When channels are cleaned up OpenHandle is most of the time
already 0. Ignore the argument checks for
CHANNEL_EVENT_WRITE_CANCELLED and CHANNEL_EVENT_WRITE_COMPLETE
only check where actually required (CHANNEL_EVENT_DATA_RECEIVED)
This commit is contained in:
Armin Novak 2020-01-29 08:52:25 +01:00
parent 8c8e5e4239
commit d2aef75004
7 changed files with 42 additions and 49 deletions

View File

@ -856,15 +856,14 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam,
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
cliprdrPlugin* cliprdr = (cliprdrPlugin*)lpUserParam; cliprdrPlugin* cliprdr = (cliprdrPlugin*)lpUserParam;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if (!cliprdr || (cliprdr->OpenHandle != openHandle)) if (!cliprdr || (cliprdr->OpenHandle != openHandle))
{ {
WLog_ERR(TAG, "error no match"); WLog_ERR(TAG, "error no match");
return; return;
} }
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = cliprdr_virtual_channel_event_data_received(cliprdr, pData, dataLength, if ((error = cliprdr_virtual_channel_event_data_received(cliprdr, pData, dataLength,
totalLength, dataFlags))) totalLength, dataFlags)))
WLog_ERR(TAG, "failed with error %" PRIu32 "", error); WLog_ERR(TAG, "failed with error %" PRIu32 "", error);
@ -883,7 +882,7 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event_ex(LPVOID lpUserParam,
break; break;
} }
if (error && cliprdr->context->rdpcontext) if (error && cliprdr && cliprdr->context->rdpcontext)
setChannelError(cliprdr->context->rdpcontext, error, setChannelError(cliprdr->context->rdpcontext, error,
"cliprdr_virtual_channel_open_event_ex reported an error"); "cliprdr_virtual_channel_open_event_ex reported an error");
} }

View File

@ -1246,15 +1246,14 @@ static void VCAPITYPE drdynvc_virtual_channel_open_event_ex(LPVOID lpUserParam,
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
drdynvcPlugin* drdynvc = (drdynvcPlugin*)lpUserParam; drdynvcPlugin* drdynvc = (drdynvcPlugin*)lpUserParam;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if (!drdynvc || (drdynvc->OpenHandle != openHandle)) if (!drdynvc || (drdynvc->OpenHandle != openHandle))
{ {
WLog_ERR(TAG, "drdynvc_virtual_channel_open_event: error no match"); WLog_ERR(TAG, "drdynvc_virtual_channel_open_event: error no match");
return; return;
} }
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = drdynvc_virtual_channel_event_data_received(drdynvc, pData, dataLength, if ((error = drdynvc_virtual_channel_event_data_received(drdynvc, pData, dataLength,
totalLength, dataFlags))) totalLength, dataFlags)))
WLog_Print(drdynvc->log, WLOG_ERROR, WLog_Print(drdynvc->log, WLOG_ERROR,
@ -1276,7 +1275,7 @@ static void VCAPITYPE drdynvc_virtual_channel_open_event_ex(LPVOID lpUserParam,
break; break;
} }
if (error && drdynvc->rdpcontext) if (error && drdynvc && drdynvc->rdpcontext)
setChannelError(drdynvc->rdpcontext, error, setChannelError(drdynvc->rdpcontext, error,
"drdynvc_virtual_channel_open_event reported an error"); "drdynvc_virtual_channel_open_event reported an error");
} }

View File

@ -1046,15 +1046,14 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event_ex(LPVOID lpUserParam,
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
encomspPlugin* encomsp = (encomspPlugin*)lpUserParam; encomspPlugin* encomsp = (encomspPlugin*)lpUserParam;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if (!encomsp || (encomsp->OpenHandle != openHandle)) if (!encomsp || (encomsp->OpenHandle != openHandle))
{ {
WLog_ERR(TAG, "error no match"); WLog_ERR(TAG, "error no match");
return; return;
} }
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = encomsp_virtual_channel_event_data_received(encomsp, pData, dataLength, if ((error = encomsp_virtual_channel_event_data_received(encomsp, pData, dataLength,
totalLength, dataFlags))) totalLength, dataFlags)))
WLog_ERR(TAG, WLog_ERR(TAG,
@ -1076,7 +1075,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event_ex(LPVOID lpUserParam,
break; break;
} }
if (error && encomsp->rdpcontext) if (error && encomsp && encomsp->rdpcontext)
setChannelError(encomsp->rdpcontext, error, setChannelError(encomsp->rdpcontext, error,
"encomsp_virtual_channel_open_event reported an error"); "encomsp_virtual_channel_open_event reported an error");

View File

@ -583,15 +583,14 @@ static VOID VCAPITYPE rail_virtual_channel_open_event_ex(LPVOID lpUserParam, DWO
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
railPlugin* rail = (railPlugin*)lpUserParam; railPlugin* rail = (railPlugin*)lpUserParam;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if (!rail || (rail->OpenHandle != openHandle)) if (!rail || (rail->OpenHandle != openHandle))
{ {
WLog_ERR(TAG, "error no match"); WLog_ERR(TAG, "error no match");
return; return;
} }
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = rail_virtual_channel_event_data_received(rail, pData, dataLength, if ((error = rail_virtual_channel_event_data_received(rail, pData, dataLength,
totalLength, dataFlags))) totalLength, dataFlags)))
WLog_ERR(TAG, WLog_ERR(TAG,
@ -612,7 +611,7 @@ static VOID VCAPITYPE rail_virtual_channel_open_event_ex(LPVOID lpUserParam, DWO
break; break;
} }
if (error && rail->rdpcontext) if (error && rail && rail->rdpcontext)
setChannelError(rail->rdpcontext, error, setChannelError(rail->rdpcontext, error,
"rail_virtual_channel_open_event reported an error"); "rail_virtual_channel_open_event reported an error");

View File

@ -1509,15 +1509,14 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DW
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
rdpdrPlugin* rdpdr = (rdpdrPlugin*)lpUserParam; rdpdrPlugin* rdpdr = (rdpdrPlugin*)lpUserParam;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if (!rdpdr || !pData || (rdpdr->OpenHandle != openHandle)) if (!rdpdr || !pData || (rdpdr->OpenHandle != openHandle))
{ {
WLog_ERR(TAG, "error no match"); WLog_ERR(TAG, "error no match");
return; return;
} }
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = rdpdr_virtual_channel_event_data_received(rdpdr, pData, dataLength, if ((error = rdpdr_virtual_channel_event_data_received(rdpdr, pData, dataLength,
totalLength, dataFlags))) totalLength, dataFlags)))
WLog_ERR(TAG, WLog_ERR(TAG,
@ -1538,7 +1537,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event_ex(LPVOID lpUserParam, DW
break; break;
} }
if (error && rdpdr->rdpcontext) if (error && rdpdr && rdpdr->rdpcontext)
setChannelError(rdpdr->rdpcontext, error, setChannelError(rdpdr->rdpcontext, error,
"rdpdr_virtual_channel_open_event_ex reported an error"); "rdpdr_virtual_channel_open_event_ex reported an error");

View File

@ -967,15 +967,14 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, D
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
rdpsndPlugin* rdpsnd = (rdpsndPlugin*)lpUserParam; rdpsndPlugin* rdpsnd = (rdpsndPlugin*)lpUserParam;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if (!rdpsnd || (rdpsnd->OpenHandle != openHandle)) if (!rdpsnd || (rdpsnd->OpenHandle != openHandle))
{ {
WLog_ERR(TAG, "error no match"); WLog_ERR(TAG, "error no match");
return; return;
} }
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = rdpsnd_virtual_channel_event_data_received(rdpsnd, pData, dataLength, if ((error = rdpsnd_virtual_channel_event_data_received(rdpsnd, pData, dataLength,
totalLength, dataFlags))) totalLength, dataFlags)))
WLog_ERR(TAG, WLog_ERR(TAG,
@ -996,7 +995,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, D
break; break;
} }
if (error && rdpsnd->rdpcontext) if (error && rdpsnd && rdpsnd->rdpcontext)
setChannelError(rdpsnd->rdpcontext, error, setChannelError(rdpsnd->rdpcontext, error,
"rdpsnd_virtual_channel_open_event_ex reported an error"); "rdpsnd_virtual_channel_open_event_ex reported an error");
} }

View File

@ -771,15 +771,14 @@ static VOID VCAPITYPE remdesk_virtual_channel_open_event_ex(LPVOID lpUserParam,
UINT error = CHANNEL_RC_OK; UINT error = CHANNEL_RC_OK;
remdeskPlugin* remdesk = (remdeskPlugin*)lpUserParam; remdeskPlugin* remdesk = (remdeskPlugin*)lpUserParam;
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if (!remdesk || (remdesk->OpenHandle != openHandle)) if (!remdesk || (remdesk->OpenHandle != openHandle))
{ {
WLog_ERR(TAG, "error no match"); WLog_ERR(TAG, "error no match");
return; return;
} }
switch (event)
{
case CHANNEL_EVENT_DATA_RECEIVED:
if ((error = remdesk_virtual_channel_event_data_received(remdesk, pData, dataLength, if ((error = remdesk_virtual_channel_event_data_received(remdesk, pData, dataLength,
totalLength, dataFlags))) totalLength, dataFlags)))
WLog_ERR(TAG, WLog_ERR(TAG,
@ -805,7 +804,7 @@ static VOID VCAPITYPE remdesk_virtual_channel_open_event_ex(LPVOID lpUserParam,
error = ERROR_INTERNAL_ERROR; error = ERROR_INTERNAL_ERROR;
} }
if (error && remdesk->rdpcontext) if (error && remdesk && remdesk->rdpcontext)
setChannelError(remdesk->rdpcontext, error, setChannelError(remdesk->rdpcontext, error,
"remdesk_virtual_channel_open_event_ex reported an error"); "remdesk_virtual_channel_open_event_ex reported an error");
} }