From f0d0105d5067b1224bb060e43cbd6bf9734f12b6 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 28 Oct 2024 08:21:08 +0100 Subject: [PATCH] [client,common] tighten /vmconnect checks Fixes #5300: * abort if +/-nego is used, /vmconnect overrides these. * only set custom port if no /port or /v:host:port is in use allowing overriding default port --- client/common/cmdline.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index a43ae5073..31dbf71cc 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -2604,7 +2604,12 @@ static int parse_vmconnect_options(rdpSettings* settings, const COMMAND_LINE_ARG if (!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE)) return COMMAND_LINE_ERROR; - if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, 2179)) + + UINT32 port = freerdp_settings_get_uint32(settings, FreeRDP_ServerPort); + if (port == 3389) + port = 2179; + + if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, port)) return COMMAND_LINE_ERROR; if (!freerdp_settings_set_bool(settings, FreeRDP_NegotiateSecurityLayer, FALSE)) return COMMAND_LINE_ERROR; @@ -5466,6 +5471,16 @@ static int freerdp_client_settings_parse_command_line_arguments_int( return fail_at(arg, COMMAND_LINE_ERROR); } + if (freerdp_settings_get_bool(settings, FreeRDP_VmConnectMode)) + { + const COMMAND_LINE_ARGUMENT_A* nego = CommandLineFindArgumentA(largs, "nego"); + if (nego) + return fail_at(arg, COMMAND_LINE_ERROR); + + const UINT32 port = freerdp_settings_get_uint32(settings, FreeRDP_ServerPort); + WLog_INFO(TAG, "/vmconnect uses custom port %" PRIu32, port); + } + fill_credential_strings(largs); return status;