server/proxy: Refactor pf_server_parse_target_from_routing_token
@@ -82,9 +82,19 @@ 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)
{
+ /* 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);
@@ -111,10 +121,6 @@ static BOOL pf_server_parse_target_from_routing_token(freerdp_peer* client,
return TRUE;
}
- /* no routing token */
- return FALSE;
-}
-
/* Event callbacks */
/**
* This callback is called when the entire connection sequence is done (as
