Author: khornicek
Date: Wed Jan 18 13:09:18 2012
New Revision: 55003
URL:
http://svn.reactos.org/svn/reactos?rev=55003&view=rev
Log:
[MSTSC]
- Fix some corner cases for settings parsing (empty values, values containing
delimiters).
- If provided, take port number into account.
Modified:
trunk/reactos/base/applications/mstsc/settings.c
trunk/reactos/base/applications/mstsc/win32.c
Modified: trunk/reactos/base/applications/mstsc/settings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/se…
==============================================================================
--- trunk/reactos/base/applications/mstsc/settings.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/settings.c [iso-8859-1] Wed Jan 18 13:09:18
2012
@@ -230,6 +230,7 @@
{
LPWSTR lpStr = lpBuffer;
WCHAR szSeps[] = L":\r\n";
+ WCHAR szNewline[] = L"\r\n";
LPWSTR lpToken;
BOOL bFound;
INT i;
@@ -258,7 +259,7 @@
else if (lpToken[0] == L's')
{
pRdpSettings->pSettings[i].Type = lpToken[0];
- lpToken = wcstok(NULL, szSeps);
+ lpToken = wcstok(NULL, szNewline);
if (lpToken != NULL)
wcscpy(pRdpSettings->pSettings[i].Value.s, lpToken);
}
@@ -268,10 +269,7 @@
/* move past the type and value */
if (!bFound)
- {
- lpToken = wcstok(NULL, szSeps);
- lpToken = wcstok(NULL, szSeps);
- }
+ lpToken = wcstok(NULL, szNewline);
/* move to next key */
lpToken = wcstok(NULL, szSeps);
Modified: trunk/reactos/base/applications/mstsc/win32.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mstsc/wi…
==============================================================================
--- trunk/reactos/base/applications/mstsc/win32.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/mstsc/win32.c [iso-8859-1] Wed Jan 18 13:09:18 2012
@@ -958,6 +958,29 @@
}
+static INT
+GetPortNumber(PCHAR szAddress)
+{
+ PCHAR szPort;
+ INT iPort = TCP_PORT_RDP;
+
+ szPort = strtok(szAddress, ":");
+
+ if (szPort != NULL)
+ {
+ szPort = strtok(NULL, ":");
+
+ if (szPort != NULL)
+ {
+ iPort = atoi(szPort);
+
+ if (iPort <= 0 || iPort > 0xFFFF)
+ iPort = TCP_PORT_RDP;
+ }
+ }
+
+ return iPort;
+}
static BOOL
ParseCommandLine(LPWSTR lpCmdLine,
@@ -1051,8 +1074,9 @@
uni_to_str(szValue, GetStringFromSettings(pRdpSettings, L"full
address"));
+ /* GetPortNumber also removes possible trailing port number from
address */
+ g_tcp_port_rdp = GetPortNumber(szValue);
strcpy(g_servername, szValue);
- //g_port = 3389;
strcpy(g_username, "");
strcpy(g_password, "");
g_server_depth = GetIntegerFromSettings(pRdpSettings, L"session
bpp");