aboutsummaryrefslogtreecommitdiffstats
path: root/community/freerdp/freerdp-args.patch
blob: d9b7eca16ab834b4f65e18347a092193ab3a69de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
diff --git a/client/common/cmdline.c b/client/common/cmdline.c
index f1f9640..72bbd12 100644
--- a/client/common/cmdline.c
+++ b/client/common/cmdline.c
@@ -1078,8 +1078,10 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
 	if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT)
 		return compatibility;
 
-	if (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 --git a/client/common/compatibility.c b/client/common/compatibility.c
index 3a7d0da..d6efe50 100644
--- a/client/common/compatibility.c
+++ b/client/common/compatibility.c
@@ -122,16 +122,20 @@ void freerdp_client_old_parse_hostname(char* str, char** ServerHostname, UINT32*
 
 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;
 		WLog_WARN(TAG,  "--plugin cliprdr -> +clipboard");
 	}
 	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))
 		{
@@ -159,21 +163,26 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
 	}
 	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
@@ -181,14 +190,12 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
 		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))
 	{
@@ -204,11 +211,10 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
 				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
 		{
@@ -218,6 +224,7 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
 
 	if (strcmp("--plugin", argv[index]) == 0)
 	{
+		int args_handled = 0;
 		int length;
 		char *a, *p;
 		int i, j, t;
@@ -233,20 +240,19 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
 			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++)
 				{
@@ -267,6 +273,9 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
 					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);
@@ -281,11 +290,14 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
 					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++;
 			}
@@ -294,19 +306,16 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
 		{
 			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;