Fixed #4249: Corruption due to recursive parser
This commit is contained in:
parent
785c42f463
commit
65482ee9bf
@ -231,12 +231,12 @@ static void freerdp_client_print_command_line_args(COMMAND_LINE_ARGUMENT_A* arg)
|
||||
|| (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
|
||||
{
|
||||
BOOL overlong = FALSE;
|
||||
|
||||
printf(" %s", "/");
|
||||
|
||||
if (arg->Format)
|
||||
{
|
||||
size_t length = (strlen(arg->Name) + strlen(arg->Format) + 2);
|
||||
|
||||
if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
|
||||
length += 2;
|
||||
|
||||
@ -314,7 +314,6 @@ BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
|
||||
printf("Multimedia Redirection: /multimedia:sys:alsa\n");
|
||||
printf("USB Device Redirection: /usb:id,dev:054c:0268\n");
|
||||
printf("\n");
|
||||
|
||||
printf("For Gateways, the https_proxy environment variable is respected:\n");
|
||||
#ifdef _WIN32
|
||||
printf(" set HTTPS_PROXY=http://proxy.contoso.com:3128/\n");
|
||||
@ -323,7 +322,6 @@ BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
|
||||
#endif
|
||||
printf(" xfreerdp /g:rdp.contoso.com ...\n");
|
||||
printf("\n");
|
||||
|
||||
printf("More documentation is coming, in the meantime consult source files\n");
|
||||
printf("\n");
|
||||
return TRUE;
|
||||
@ -347,10 +345,6 @@ static int freerdp_client_command_line_pre_filter(void* context, int index,
|
||||
if (!(settings->ConnectionFile = _strdup(argv[index])))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
if (freerdp_client_settings_parse_connection_file(settings,
|
||||
settings->ConnectionFile))
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -364,10 +358,6 @@ static int freerdp_client_command_line_pre_filter(void* context, int index,
|
||||
if (!(settings->AssistanceFile = _strdup(argv[index])))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
if (freerdp_client_settings_parse_assistance_file(settings,
|
||||
settings->AssistanceFile) < 0)
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1078,6 +1068,7 @@ BOOL freerdp_parse_hostname(char* hostname, char** host, int* port)
|
||||
|
||||
if ((errno != 0) || (val <= 0) || (val > UINT16_MAX))
|
||||
return FALSE;
|
||||
|
||||
*host = (char*) calloc(length + 1UL, sizeof(char));
|
||||
|
||||
if (!(*host))
|
||||
@ -1489,13 +1480,31 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandLineClearArgumentsA(args);
|
||||
|
||||
if (allowUnknown)
|
||||
{
|
||||
flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
|
||||
}
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
const char* ext = strstr(argv[1], ".rdp");
|
||||
const char* assist = strstr(argv[1], ".msrcIncident");
|
||||
|
||||
if (ext)
|
||||
{
|
||||
if (freerdp_client_settings_parse_connection_file(settings, argv[1]))
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
}
|
||||
|
||||
if (assist)
|
||||
{
|
||||
if (freerdp_client_settings_parse_assistance_file(settings,
|
||||
settings->AssistanceFile) < 0)
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
CommandLineClearArgumentsA(args);
|
||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags,
|
||||
settings,
|
||||
freerdp_client_command_line_pre_filter,
|
||||
@ -1532,6 +1541,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
|
||||
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
|
||||
length = (int)(p - arg->Value);
|
||||
settings->ServerPort = val;
|
||||
|
||||
@ -1665,6 +1675,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
settings->PercentScreenUseWidth = 1;
|
||||
partial = TRUE;
|
||||
}
|
||||
|
||||
if (strchr(p, 'h'))
|
||||
{
|
||||
settings->PercentScreenUseHeight = 1;
|
||||
@ -1869,6 +1880,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
|
||||
if (rc <= 0)
|
||||
return COMMAND_LINE_STATUS_PRINT;
|
||||
|
||||
id = rc;
|
||||
}
|
||||
|
||||
@ -1933,6 +1945,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
|
||||
if ((errno != 0) || (val == 0) || (val > UINT16_MAX))
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
|
||||
length = (int)(p - arg->Value);
|
||||
settings->GatewayPort = val;
|
||||
|
||||
@ -2052,6 +2065,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
long type;
|
||||
char* pEnd;
|
||||
type = strtol(arg->Value, &pEnd, 10);
|
||||
|
||||
if (errno != 0)
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
|
||||
@ -2192,6 +2206,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
long type;
|
||||
char* pEnd;
|
||||
type = strtol(arg->Value, &pEnd, 10);
|
||||
|
||||
if (errno != 0)
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
|
||||
@ -2258,6 +2273,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
if (arg->Value)
|
||||
{
|
||||
#ifdef WITH_GFX_H264
|
||||
|
||||
if (_strnicmp("AVC444", arg->Value, 6) == 0)
|
||||
{
|
||||
settings->GfxH264 = TRUE;
|
||||
@ -2276,8 +2292,10 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
CommandLineSwitchCase(arg, "gfx-thin-client")
|
||||
{
|
||||
settings->GfxThinClient = arg->Value ? TRUE : FALSE;
|
||||
|
||||
if (settings->GfxThinClient)
|
||||
settings->GfxSmallCache = TRUE;
|
||||
|
||||
settings->SupportGraphicsPipeline = TRUE;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gfx-small-cache")
|
||||
@ -2366,6 +2384,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
|
||||
if ((errno != 0) || (val > UINT32_MAX))
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
|
||||
settings->SendPreconnectionPdu = TRUE;
|
||||
settings->PreconnectionId = val;
|
||||
}
|
||||
@ -2556,6 +2575,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
{
|
||||
settings->NSCodec = TRUE;
|
||||
}
|
||||
|
||||
#if defined(WITH_JPEG)
|
||||
else if (strcmp(arg->Value, "jpeg") == 0)
|
||||
{
|
||||
@ -2564,6 +2584,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
if (settings->JpegQuality == 0)
|
||||
settings->JpegQuality = 75;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
CommandLineSwitchCase(arg, "fast-path")
|
||||
|
Loading…
Reference in New Issue
Block a user