192 lines
4.7 KiB
Diff
192 lines
4.7 KiB
Diff
From 802647fa254b761dc01240bcf4e94740aa39e894 Mon Sep 17 00:00:00 2001
|
|
From: Armin Novak <armin.novak@thincast.com>
|
|
Date: Thu, 2 Jul 2026 08:34:18 +0200
|
|
Subject: [PATCH] [client,common] deprecate freerdp command line options in rdp
|
|
files
|
|
|
|
---
|
|
client/common/file.c | 140 ++++++++++++++++++++-----------------------
|
|
1 file changed, 64 insertions(+), 76 deletions(-)
|
|
|
|
diff --git a/client/common/file.c b/client/common/file.c
|
|
index 35e8643f2..f178cad23 100644
|
|
--- a/client/common/file.c
|
|
+++ b/client/common/file.c
|
|
@@ -774,16 +774,6 @@ static SSIZE_T freerdp_client_rdp_file_add_line(rdpFile* file)
|
|
return index;
|
|
}
|
|
|
|
-static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file, char* name, char* value)
|
|
-{
|
|
- return freerdp_client_rdp_file_set_string(file, name, value);
|
|
-}
|
|
-
|
|
-static BOOL freerdp_client_parse_rdp_file_option(rdpFile* file, const char* option)
|
|
-{
|
|
- return freerdp_client_add_option(file, option);
|
|
-}
|
|
-
|
|
BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, const BYTE* buffer, size_t size)
|
|
{
|
|
return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size, NULL);
|
|
@@ -884,19 +874,67 @@ static BOOL trim_strings(rdpFile* file)
|
|
return TRUE;
|
|
}
|
|
|
|
+static BOOL parse_line(rdpFile* file, char* line, size_t length, rdp_file_fkt_parse parse)
|
|
+{
|
|
+ if (length <= 1)
|
|
+ return TRUE;
|
|
+
|
|
+ const char* beg = line;
|
|
+#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
|
|
+ if (beg[0] == '/')
|
|
+ {
|
|
+ if (!freerdp_client_add_option(file, line))
|
|
+ return FALSE;
|
|
+
|
|
+ return TRUE; /* FreeRDP option */
|
|
+ }
|
|
+#endif
|
|
+
|
|
+ char* d1 = strchr(line, ':');
|
|
+
|
|
+ if (!d1)
|
|
+ return TRUE; /* not first delimiter */
|
|
+
|
|
+ const char* type = &d1[1];
|
|
+ char* d2 = strchr(type, ':');
|
|
+
|
|
+ if (!d2)
|
|
+ return TRUE; /* no second delimiter */
|
|
+
|
|
+ if ((d2 - d1) != 2)
|
|
+ return TRUE; /* improper type length */
|
|
+
|
|
+ *d1 = 0;
|
|
+ *d2 = 0;
|
|
+ const char* name = beg;
|
|
+ const char* value = &d2[1];
|
|
+
|
|
+ if (parse && parse(file->context, name, *type, value))
|
|
+ return TRUE;
|
|
+
|
|
+ if (*type == 'i')
|
|
+ {
|
|
+ /* integer type */
|
|
+ return freerdp_client_parse_rdp_file_integer(file, name, value);
|
|
+ }
|
|
+ if (*type == 's')
|
|
+ {
|
|
+ /* string type */
|
|
+ return freerdp_client_rdp_file_set_string(file, name, value);
|
|
+ }
|
|
+ if (*type == 'b')
|
|
+ {
|
|
+ /* binary type */
|
|
+ WLog_ERR(TAG, "Unsupported RDP file binary option %s [value=%s]", name, value);
|
|
+ }
|
|
+
|
|
+ return TRUE;
|
|
+}
|
|
+
|
|
BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer, size_t size,
|
|
rdp_file_fkt_parse parse)
|
|
{
|
|
BOOL rc = FALSE;
|
|
- size_t length = 0;
|
|
- char* line = NULL;
|
|
- char* type = NULL;
|
|
- char* context = NULL;
|
|
- char* d1 = NULL;
|
|
- char* d2 = NULL;
|
|
- char* beg = NULL;
|
|
- char* name = NULL;
|
|
- char* value = NULL;
|
|
char* copy = NULL;
|
|
|
|
if (!file)
|
|
@@ -907,9 +945,8 @@ BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer,
|
|
if ((buffer[0] == BOM_UTF16_LE[0]) && (buffer[1] == BOM_UTF16_LE[1]))
|
|
{
|
|
LPCWSTR uc = (LPCWSTR)(&buffer[2]);
|
|
- size = size / sizeof(WCHAR) - 1;
|
|
-
|
|
- copy = ConvertWCharNToUtf8Alloc(uc, size, NULL);
|
|
+ const size_t charlen = size / sizeof(WCHAR) - 1;
|
|
+ copy = ConvertWCharNToUtf8Alloc(uc, charlen, &size);
|
|
if (!copy)
|
|
{
|
|
WLog_ERR(TAG, "Failed to convert RDP file from UCS2 to UTF8");
|
|
@@ -926,65 +963,16 @@ BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer,
|
|
memcpy(copy, buffer, size);
|
|
}
|
|
|
|
- line = strtok_s(copy, "\r\n", &context);
|
|
+ char* context = NULL;
|
|
+ char* line = strtok_s(copy, "\r\n", &context);
|
|
|
|
while (line)
|
|
{
|
|
- length = strnlen(line, size);
|
|
-
|
|
- if (length > 1)
|
|
- {
|
|
- beg = line;
|
|
- if (beg[0] == '/')
|
|
- {
|
|
- if (!freerdp_client_parse_rdp_file_option(file, line))
|
|
- goto fail;
|
|
-
|
|
- goto next_line; /* FreeRDP option */
|
|
- }
|
|
-
|
|
- d1 = strchr(line, ':');
|
|
-
|
|
- if (!d1)
|
|
- goto next_line; /* not first delimiter */
|
|
+ const size_t length = strnlen(line, size);
|
|
|
|
- type = &d1[1];
|
|
- d2 = strchr(type, ':');
|
|
-
|
|
- if (!d2)
|
|
- goto next_line; /* no second delimiter */
|
|
-
|
|
- if ((d2 - d1) != 2)
|
|
- goto next_line; /* improper type length */
|
|
-
|
|
- *d1 = 0;
|
|
- *d2 = 0;
|
|
- name = beg;
|
|
- value = &d2[1];
|
|
-
|
|
- if (parse && parse(file->context, name, *type, value))
|
|
- {
|
|
- }
|
|
- else if (*type == 'i')
|
|
- {
|
|
- /* integer type */
|
|
- if (!freerdp_client_parse_rdp_file_integer(file, name, value))
|
|
- goto fail;
|
|
- }
|
|
- else if (*type == 's')
|
|
- {
|
|
- /* string type */
|
|
- if (!freerdp_client_parse_rdp_file_string(file, name, value))
|
|
- goto fail;
|
|
- }
|
|
- else if (*type == 'b')
|
|
- {
|
|
- /* binary type */
|
|
- WLog_ERR(TAG, "Unsupported RDP file binary option %s [value=%s]", name, value);
|
|
- }
|
|
- }
|
|
+ if (!parse_line(file, line, length, parse))
|
|
+ goto fail;
|
|
|
|
- next_line:
|
|
line = strtok_s(NULL, "\r\n", &context);
|
|
}
|
|
|