server/proxy: Refactor pf_server_parse_target_from_routing_token
This commit is contained in:
parent
a39658fc2a
commit
c4d72c6ad2
@ -82,37 +82,43 @@ static BOOL pf_server_parse_target_from_routing_token(freerdp_peer* client,
|
||||
DWORD routing_token_length;
|
||||
const char* routing_token = freerdp_nego_get_routing_token(client->context, &routing_token_length);
|
||||
|
||||
if (routing_token &&
|
||||
(routing_token_length > prefix_len) && (routing_token_length < TARGET_MAX))
|
||||
if (routing_token == NULL)
|
||||
{
|
||||
len = routing_token_length - prefix_len;
|
||||
*target = malloc(len + 1);
|
||||
|
||||
if (!(*target))
|
||||
return FALSE;
|
||||
|
||||
CopyMemory(*target, routing_token + prefix_len, len);
|
||||
*(*target + len) = '\0';
|
||||
colon = strchr(*target, ':');
|
||||
WLog_INFO(TAG, "Target [parsed from routing token]: %s", *target);
|
||||
|
||||
if (colon)
|
||||
{
|
||||
/* port is specified */
|
||||
unsigned long p = strtoul(colon + 1, NULL, 10);
|
||||
|
||||
if (p > USHRT_MAX)
|
||||
return FALSE;
|
||||
|
||||
*port = (DWORD)p;
|
||||
*colon = '\0';
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
/* no routing token */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* no routing token */
|
||||
return FALSE;
|
||||
if ((routing_token_length <= prefix_len) || (routing_token_length >= TARGET_MAX))
|
||||
{
|
||||
WLog_ERR(TAG, "pf_server_parse_target_from_routing_token: bad routing token length: %i",
|
||||
routing_token_length);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
len = routing_token_length - prefix_len;
|
||||
*target = malloc(len + 1);
|
||||
|
||||
if (!(*target))
|
||||
return FALSE;
|
||||
|
||||
CopyMemory(*target, routing_token + prefix_len, len);
|
||||
*(*target + len) = '\0';
|
||||
colon = strchr(*target, ':');
|
||||
WLog_INFO(TAG, "Target [parsed from routing token]: %s", *target);
|
||||
|
||||
if (colon)
|
||||
{
|
||||
/* port is specified */
|
||||
unsigned long p = strtoul(colon + 1, NULL, 10);
|
||||
|
||||
if (p > USHRT_MAX)
|
||||
return FALSE;
|
||||
|
||||
*port = (DWORD)p;
|
||||
*colon = '\0';
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Event callbacks */
|
||||
|
Loading…
Reference in New Issue
Block a user