Use better upstream patch to fix command line parsing

This commit is contained in:
Orion Poplawski 2015-01-15 14:55:02 -07:00
parent 5005bca61c
commit a8547c7cf3
2 changed files with 172 additions and 12 deletions

View File

@ -1,27 +1,184 @@
diff -up FreeRDP-1.2.0-beta1-android9/client/common/cmdline.c.args FreeRDP-1.2.0-beta1-android9/client/common/cmdline.c
--- FreeRDP-1.2.0-beta1-android9/client/common/cmdline.c.args 2015-01-14 15:53:01.654250627 -0700
+++ FreeRDP-1.2.0-beta1-android9/client/common/cmdline.c 2015-01-14 15:54:14.634837903 -0700
@@ -1087,7 +1087,7 @@ BOOL freerdp_client_detect_command_line(
--- FreeRDP-1.2.0-beta1-android9/client/common/cmdline.c.args 2015-01-15 14:38:15.573870682 -0700
+++ FreeRDP-1.2.0-beta1-android9/client/common/cmdline.c 2015-01-15 14:51:29.640391722 -0700
@@ -1087,8 +1087,10 @@ BOOL freerdp_client_detect_command_line(
*flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
*flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
- if (windows_cli_count >= posix_cli_count)
+ if ((windows_cli_count >= 0) && (windows_cli_count >= posix_cli_count))
+ /* Check, if this may be windows style syntax... */
+ if (windows_cli_count && (windows_cli_count >= posix_cli_count) || (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
{
+ windows_cli_count = 1;
*flags = COMMAND_LINE_SEPARATOR_COLON;
*flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
}
diff -up FreeRDP-1.2.0-beta1-android9/client/common/compatibility.c.args FreeRDP-1.2.0-beta1-android9/client/common/compatibility.c
--- FreeRDP-1.2.0-beta1-android9/client/common/compatibility.c.args 2014-09-11 16:46:32.000000000 -0600
+++ FreeRDP-1.2.0-beta1-android9/client/common/compatibility.c 2015-01-14 15:53:01.655250622 -0700
@@ -262,8 +262,10 @@ int freerdp_client_old_command_line_pre_
}
+++ FreeRDP-1.2.0-beta1-android9/client/common/compatibility.c 2015-01-15 14:53:19.418773129 -0700
@@ -119,16 +119,20 @@ void freerdp_client_old_parse_hostname(c
if (p != NULL)
- {
p = strchr(p, ':');
int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
{
+ int args_handled = 0;
if (strcmp(args->argv[0], "cliprdr") == 0)
{
+ args_handled++;
settings->RedirectClipboard = TRUE;
DEBUG_WARN( "--plugin cliprdr -> +clipboard\n");
}
else if (strcmp(args->argv[0], "rdpdr") == 0)
{
+ args_handled++;
if (args->argc < 2)
- return -1;
+ return 1;
+ args_handled++;
if ((strcmp(args->argv[1], "disk") == 0) ||
(strcmp(args->argv[1], "drive") == 0))
{
@@ -156,21 +160,26 @@ int freerdp_client_old_process_plugin(rd
}
else if (strcmp(args->argv[0], "drdynvc") == 0)
{
+ args_handled++;
freerdp_client_add_dynamic_channel(settings, args->argc - 1, &args->argv[1]);
}
else if (strcmp(args->argv[0], "rdpsnd") == 0)
{
+ args_handled++;
if (args->argc < 2)
- return -1;
+ return 1;
+ args_handled++;
freerdp_addin_replace_argument_value(args, args->argv[1], "sys", args->argv[1]);
freerdp_client_add_static_channel(settings, args->argc, args->argv);
}
else if (strcmp(args->argv[0], "rail") == 0)
{
+ args_handled++;
if (args->argc < 2)
- return -1;
+ return 1;
+ args_handled++;
settings->RemoteApplicationProgram = _strdup(args->argv[1]);
}
else
@@ -178,14 +187,12 @@ int freerdp_client_old_process_plugin(rd
freerdp_client_add_static_channel(settings, args->argc, args->argv);
}
- return 1;
+ return args_handled;
}
int freerdp_client_old_command_line_pre_filter(void* context, int index, int argc, LPCSTR* argv)
{
- rdpSettings* settings;
-
- settings = (rdpSettings*) context;
+ rdpSettings* settings = (rdpSettings*) context;
if (index == (argc - 1))
{
@@ -201,11 +208,10 @@ int freerdp_client_old_command_line_pre_
return -1;
}
- if (settings)
- {
- freerdp_client_old_parse_hostname((char*) argv[index],
- &settings->ServerHostname, &settings->ServerPort);
- }
+ freerdp_client_old_parse_hostname((char*) argv[index],
+ &settings->ServerHostname, &settings->ServerPort);
+
+ return 2;
}
else
{
@@ -215,6 +221,7 @@ int freerdp_client_old_command_line_pre_
if (strcmp("--plugin", argv[index]) == 0)
{
+ int args_handled = 0;
int length;
char *a, *p;
int i, j, t;
@@ -230,20 +237,19 @@ int freerdp_client_old_command_line_pre_
return -1;
args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
- args->argv = (char**) malloc(sizeof(char*) * 5);
+ args->argv = (char**) calloc(argc, sizeof(char*));
args->argc = 1;
- args->argv[0] = _strdup(argv[t]);
-
if ((index < argc - 1) && strcmp("--data", argv[index + 1]) == 0)
{
i = 0;
index += 2;
- args->argc = 1;
while ((index < argc) && (strcmp("--", argv[index]) != 0))
{
+ args_handled ++;
args->argc = 1;
+ args->argv[0] = _strdup(argv[t]);
for (j = 0, p = (char*) argv[index]; (j < 4) && (p != NULL); j++)
{
@@ -264,6 +270,9 @@ int freerdp_client_old_command_line_pre_
if (p != NULL)
{
p = strchr(p, ':');
+ }
+ if (p != NULL)
+ {
length = (int) (p - a);
args->argv[j + 1] = (char*) malloc(length + 1);
CopyMemory(args->argv[j + 1], a, length);
@@ -278,11 +287,14 @@ int freerdp_client_old_command_line_pre_
args->argc++;
}
- if (settings->instance)
+ if (settings)
{
freerdp_client_old_process_plugin(settings, args);
}
+ for (i = 0; i < args->argc; i++)
+ free(args->argv[i]);
+ memset(args->argv, 0, argc * sizeof(char*));
index++;
i++;
}
@@ -291,19 +303,16 @@ int freerdp_client_old_command_line_pre_
{
if (settings)
{
- if (settings->instance)
- {
- freerdp_client_old_process_plugin(settings, args);
- }
+ args->argv[0] = _strdup(argv[t]);
+ args_handled = freerdp_client_old_process_plugin(settings, args);
+ free (args->argv[0]);
}
}
- for (i = 0; i < args->argc; i++)
- free(args->argv[i]);
free(args->argv);
free(args);
- return (index - old_index);
+ return (index - old_index) + args_handled;
}
return 0;

View File

@ -1,6 +1,6 @@
Name: freerdp
Version: 1.2.0
Release: 0.5.beta.1%{?dist}
Release: 0.6.beta.1%{?dist}
Epoch: 1
Summary: Free implementation of the Remote Desktop Protocol (RDP)
@ -11,7 +11,7 @@ Patch0: freerdp-aarch64.patch
# https://github.com/FreeRDP/FreeRDP/commit/1b663ceffe51008af7ae9749e5b7999b2f7d6698
Patch1: freerdp-cmake-list.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1150349
# https://github.com/FreeRDP/FreeRDP/pull/2305
# https://github.com/FreeRDP/FreeRDP/pull/2310
Patch2: freerdp-args.patch
BuildRequires: alsa-lib-devel
@ -187,6 +187,9 @@ find %{buildroot} -name "*.a" -delete
%{_libdir}/pkgconfig/winpr.pc
%changelog
* Thu Jan 15 2015 Orion Poplawski <orion@cora.nwra.com> - 1:1.2.0-0.6.beta.1
- Use better upstream patch to fix command line parsing
* Wed Jan 14 2015 Orion Poplawski <orion@cora.nwra.com> - 1:1.2.0-0.5.beta.1
- Add patch to fix command line parsing segfault (bug #1150349) and to
fix old style command line options