From 1806daa3758afbd766096880062a7b16d3ac79ca Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 12 Jun 2024 09:26:48 +0200 Subject: [PATCH] [channel,server] fix unguarded use of functions If functions of channel__server are used guard them so the code compiles if the channel is not compiled in. --- channels/server/channels.c | 25 ++++++++++++++++++++++++- server/shadow/shadow_channels.c | 14 ++------------ server/shadow/shadow_client.c | 4 ++++ server/shadow/shadow_rdpgfx.c | 10 ++++++++-- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/channels/server/channels.c b/channels/server/channels.c index 35a85e8ee..19b57310d 100644 --- a/channels/server/channels.c +++ b/channels/server/channels.c @@ -45,14 +45,22 @@ #include #include #include +#if defined(CHANNEL_RAIL_SERVER) #include +#endif #include #include #include +#if defined(CHANNEL_RAIL_SERVER) #include +#endif #include +#if defined(CHANNEL_RDPGFX_SERVER) #include +#endif +#if defined(CHANNEL_DISP_SERVER) #include +#endif #if defined(CHANNEL_RDPEMSC_SERVER) #include @@ -87,13 +95,21 @@ void freerdp_channels_dummy(void) echo_server_context* echo = NULL; RdpdrServerContext* rdpdr = NULL; DrdynvcServerContext* drdynvc = NULL; +#if defined(CHANNEL_RDPEI_SERVER) RdpeiServerContext* rdpei = NULL; +#endif RemdeskServerContext* remdesk = NULL; EncomspServerContext* encomsp = NULL; +#if defined(CHANNEL_RAIL_SERVER) RailServerContext* rail = NULL; +#endif TelemetryServerContext* telemetry = NULL; +#if defined(CHANNEL_RDPGFX_SERVER) RdpgfxServerContext* rdpgfx = NULL; +#endif +#if defined(CHANNEL_DISP_SERVER) DispServerContext* disp = NULL; +#endif #if defined(CHANNEL_RDPEMSC_SERVER) MouseCursorServerContext* mouse_cursor = NULL; #endif /* CHANNEL_RDPEMSC_SERVER */ @@ -123,21 +139,28 @@ void freerdp_channels_dummy(void) rdpdr_server_context_free(rdpdr); drdynvc = drdynvc_server_context_new(NULL); drdynvc_server_context_free(drdynvc); +#if defined(CHANNEL_RDPEI_SERVER) rdpei = rdpei_server_context_new(NULL); rdpei_server_context_free(rdpei); +#endif remdesk = remdesk_server_context_new(NULL); remdesk_server_context_free(remdesk); encomsp = encomsp_server_context_new(NULL); encomsp_server_context_free(encomsp); +#if defined(CHANNEL_RAIL_SERVER) rail = rail_server_context_new(NULL); rail_server_context_free(rail); +#endif telemetry = telemetry_server_context_new(NULL); telemetry_server_context_free(telemetry); +#if defined(CHANNEL_RDPGFX_SERVER) rdpgfx = rdpgfx_server_context_new(NULL); rdpgfx_server_context_free(rdpgfx); +#endif +#if defined(CHANNEL_DISP_SERVER) disp = disp_server_context_new(NULL); disp_server_context_free(disp); - +#endif #if defined(CHANNEL_RDPEMSC_SERVER) mouse_cursor = mouse_cursor_server_context_new(NULL); mouse_cursor_server_context_free(mouse_cursor); diff --git a/server/shadow/shadow_channels.c b/server/shadow/shadow_channels.c index 07c51051a..1bf3b161f 100644 --- a/server/shadow/shadow_channels.c +++ b/server/shadow/shadow_channels.c @@ -41,26 +41,16 @@ UINT shadow_client_channels_post_connect(rdpShadowClient* client) shadow_client_audin_init(client); - if (freerdp_settings_get_bool(client->context.settings, FreeRDP_SupportGraphicsPipeline)) - { - shadow_client_rdpgfx_init(client); - } + shadow_client_rdpgfx_init(client); return CHANNEL_RC_OK; } void shadow_client_channels_free(rdpShadowClient* client) { - if (freerdp_settings_get_bool(client->context.settings, FreeRDP_SupportGraphicsPipeline)) - { - shadow_client_rdpgfx_uninit(client); - } - + shadow_client_rdpgfx_uninit(client); shadow_client_audin_uninit(client); - shadow_client_rdpsnd_uninit(client); - shadow_client_remdesk_uninit(client); - shadow_client_encomsp_uninit(client); } diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index b5aa8c243..3a8343054 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -2196,10 +2196,12 @@ static DWORD WINAPI shadow_client_thread(LPVOID arg) events[nCount++] = ChannelEvent; events[nCount++] = MessageQueue_Event(MsgQueue); +#if defined(CHANNEL_RDPGFX_SERVER) HANDLE gfxevent = rdpgfx_server_get_event_handle(client->rdpgfx); if (gfxevent) events[nCount++] = gfxevent; +#endif status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE); @@ -2329,6 +2331,7 @@ static DWORD WINAPI shadow_client_thread(LPVOID arg) } } +#if defined(CHANNEL_RDPGFX_SERVER) if (gfxevent) { if (WaitForSingleObject(gfxevent, 0) == WAIT_OBJECT_0) @@ -2336,6 +2339,7 @@ static DWORD WINAPI shadow_client_thread(LPVOID arg) rdpgfx_server_handle_messages(client->rdpgfx); } } +#endif if (WaitForSingleObject(MessageQueue_Event(MsgQueue), 0) == WAIT_OBJECT_0) { diff --git a/server/shadow/shadow_rdpgfx.c b/server/shadow/shadow_rdpgfx.c index 16bb23657..d89440619 100644 --- a/server/shadow/shadow_rdpgfx.c +++ b/server/shadow/shadow_rdpgfx.c @@ -29,11 +29,13 @@ int shadow_client_rdpgfx_init(rdpShadowClient* client) { WINPR_ASSERT(client); + if (!freerdp_settings_get_bool(client->context.settings, FreeRDP_SupportGraphicsPipeline)) + return 1; + +#if defined(CHANNEL_RDPGFX_SERVER) RdpgfxServerContext* rdpgfx = client->rdpgfx = rdpgfx_server_context_new(client->vcm); if (!rdpgfx) - { return 0; - } rdpgfx->rdpcontext = &client->context; @@ -41,15 +43,19 @@ int shadow_client_rdpgfx_init(rdpShadowClient* client) if (!IFCALLRESULT(CHANNEL_RC_OK, rdpgfx->Initialize, rdpgfx, TRUE)) return -1; +#endif return 1; } void shadow_client_rdpgfx_uninit(rdpShadowClient* client) { + WINPR_ASSERT(client); if (client->rdpgfx) { +#if defined(CHANNEL_RDPGFX_SERVER) rdpgfx_server_context_free(client->rdpgfx); +#endif client->rdpgfx = NULL; } }