fix freerdp_assistance_parse_address_list parsing (#8147)

* fix remote assistance connection string1 parsing 

Fails to parse when connection string only has one host:port because there is no ";" character. Also when multiple host:port;host:port it skip first host:port and parses remaining host:port as ";host:port...end" of connection string:
eg:
;192.168.93.138:49626;192.168.93.139:49627;192.168.93.140:49628
;192.168.93.139:49627;192.168.93.140:49628
;192.168.93.140:49628

* Update assistance.c

* Update assistance.c

* Update assistance.c
This commit is contained in:
garbb
2022-09-09 00:27:52 -07:00
committed by GitHub
parent 06827774b6
commit fff93f62ed

View File

@@ -180,30 +180,32 @@ static BOOL append_address(rdpAssistanceFile* file, const char* host, const char
static BOOL freerdp_assistance_parse_address_list(rdpAssistanceFile* file, char* list)
{
WLog_DBG(TAG, "freerdp_assistance_parse_address_list list=%s", list);
BOOL rc = FALSE;
char* p;
if (!file || !list)
return FALSE;
p = list;
char* strp = list;
char* s = ";";
char* token;
while ((p = strchr(p, ';')) != NULL)
// get the first token
token = strtok(strp, s);
// walk through other tokens
while (token != NULL)
{
char* q = strchr(p, ':');
char* port = strchr(token, ':');
*port = '\0';
port++;
if (!q)
if (!append_address(file, token, port))
goto out;
*q = '\0';
q++;
if (!append_address(file, p, q))
goto out;
p = q;
token = strtok(NULL, s);
}
rc = TRUE;
out:
return rc;