Settings fixes (#7335)

* Fix temporary settings allocation for command line

Detection of legacy command line requires a temporary settings
struct. This was previously manyally allocated instead of using
freerdp_settings_new and freerdp_settings_free.

* Fixed CommandLineParseCommaSeparatedValuesEx

The name argument was not copied into the returned array.
This commit is contained in:
akallabeth 2021-10-07 13:43:12 +02:00 committed by GitHub
parent a4be45dd5d
commit 6ac4cad8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -422,7 +422,7 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SILENCE_PARSER;
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
flags |= COMMAND_LINE_SIGIL_NOT_ESCAPED;
settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
settings = freerdp_settings_new(0);
if (!settings)
return -1;
@ -433,7 +433,7 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
if (status < 0)
{
free(settings);
freerdp_settings_free(settings);
return status;
}
@ -468,8 +468,7 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, size_t* count)
detect_status = 1;
}
free(settings->ServerHostname);
free(settings);
freerdp_settings_free(settings);
return detect_status;
}
int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSettings* settings)

View File

@ -490,7 +490,7 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list
size_t nArgs;
size_t index;
size_t nCommas;
size_t prefix, len;
size_t prefix, len, namelen = 0;
nCommas = 0;
if (count == NULL)
@ -535,7 +535,9 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list
prefix = (nArgs + 1UL) * sizeof(char*);
len = strlen(list);
p = (char**)calloc(len + prefix + 1, sizeof(char*));
if (name)
namelen = strlen(name);
p = (char**)calloc(len + prefix + 1 + namelen + 1, sizeof(char*));
if (!p)
return NULL;
@ -544,7 +546,12 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list
memcpy(str, list, len);
if (name)
p[0] = (char*)name;
{
char* namestr = &((char*)p)[prefix + len + 1];
memcpy(namestr, name, namelen);
p[0] = namestr;
}
for (index = name ? 1 : 0; index < nArgs; index++)
{