Use freerdp_settings_set and _strdup
This commit is contained in:
parent
3303aa1446
commit
cefb4e1237
@ -101,7 +101,7 @@ char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder)
|
||||
native_str = (*env)->GetStringUTFChars(env, strObj, NULL);
|
||||
if (!native_str)
|
||||
return NULL;
|
||||
result = strdup(native_str);
|
||||
result = _strdup(native_str);
|
||||
(*env)->ReleaseStringUTFChars(env, strObj, native_str);
|
||||
|
||||
return result;
|
||||
|
@ -176,28 +176,21 @@ static BOOL freerdp_client_settings_post_process(rdpSettings* settings)
|
||||
{
|
||||
if (settings->Username)
|
||||
{
|
||||
free(settings->GatewayUsername);
|
||||
settings->GatewayUsername = _strdup(settings->Username);
|
||||
|
||||
if (!settings->GatewayUsername)
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayUsername,
|
||||
settings->Username))
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
if (settings->Domain)
|
||||
{
|
||||
free(settings->GatewayDomain);
|
||||
settings->GatewayDomain = _strdup(settings->Domain);
|
||||
|
||||
if (!settings->GatewayDomain)
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayDomain, settings->Domain))
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
if (settings->Password)
|
||||
{
|
||||
free(settings->GatewayPassword);
|
||||
settings->GatewayPassword = _strdup(settings->Password);
|
||||
|
||||
if (!settings->GatewayPassword)
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayPassword,
|
||||
settings->Password))
|
||||
goto out_error;
|
||||
}
|
||||
}
|
||||
|
@ -521,7 +521,7 @@ static int freerdp_client_command_line_pre_filter(void* context, int index, int
|
||||
{
|
||||
settings = (rdpSettings*)context;
|
||||
|
||||
if (!copy_value(argv[index], &settings->ConnectionFile))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ConnectionFile, argv[index]))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
return 1;
|
||||
@ -534,7 +534,7 @@ static int freerdp_client_command_line_pre_filter(void* context, int index, int
|
||||
{
|
||||
settings = (rdpSettings*)context;
|
||||
|
||||
if (!copy_value(argv[index], &settings->AssistanceFile))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_AssistanceFile, argv[index]))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
return 1;
|
||||
@ -1605,7 +1605,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(settings->ServerHostname = _strdup(arg->Value)))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
}
|
||||
@ -1641,7 +1641,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "spn-class")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->AuthenticationServiceClass))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_AuthenticationServiceClass,
|
||||
arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "redirect-prefer")
|
||||
@ -1695,7 +1696,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
{
|
||||
settings->SendPreconnectionPdu = TRUE;
|
||||
|
||||
if (!copy_value(arg->Value, &settings->PreconnectionBlob))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
}
|
||||
@ -1855,7 +1856,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "t")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->WindowTitle))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_WindowTitle, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "decorations")
|
||||
@ -1933,12 +1934,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
settings->ConsoleSession = TRUE;
|
||||
settings->RestrictedAdminModeRequired = TRUE;
|
||||
|
||||
if (!copy_value(arg->Value, &settings->PasswordHash))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_PasswordHash, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "client-hostname")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->ClientHostname))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ClientHostname, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "kbd")
|
||||
@ -1965,7 +1966,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "kbd-remap")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->KeyboardRemappingList))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_KeyboardRemappingList, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "kbd-lang")
|
||||
@ -2019,12 +2020,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "d")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->Domain))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_Domain, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "p")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->Password))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_Password, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "g")
|
||||
@ -2057,13 +2058,14 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(settings->GatewayHostname = _strdup(arg->Value)))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayHostname, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(settings->GatewayHostname = _strdup(settings->ServerHostname)))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayHostname,
|
||||
settings->ServerHostname))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
|
||||
@ -2194,14 +2196,14 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gd")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->GatewayDomain))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayDomain, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
settings->GatewayUseSameCredentials = FALSE;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gp")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->GatewayPassword))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayPassword, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
settings->GatewayUseSameCredentials = FALSE;
|
||||
@ -2240,7 +2242,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gat")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->GatewayAccessToken))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayAccessToken, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gateway-usage-method")
|
||||
@ -2268,7 +2270,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->RemoteApplicationProgram))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationProgram,
|
||||
arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
settings->RemoteApplicationMode = TRUE;
|
||||
@ -2279,7 +2282,8 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-workdir")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->RemoteApplicationWorkingDir))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationWorkingDir,
|
||||
arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "load-balance-info")
|
||||
@ -2291,27 +2295,28 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-name")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->RemoteApplicationName))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationName, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-icon")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->RemoteApplicationIcon))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationIcon, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-cmd")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->RemoteApplicationCmdLine))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationCmdLine,
|
||||
arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-file")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->RemoteApplicationFile))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationFile, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app-guid")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->RemoteApplicationGuid))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RemoteApplicationGuid, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "compression")
|
||||
@ -2382,12 +2387,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "shell")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->AlternateShell))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_AlternateShell, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "shell-dir")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->ShellWorkingDirectory))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ShellWorkingDirectory, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "audio-mode")
|
||||
@ -2692,7 +2697,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
{
|
||||
settings->SendPreconnectionPdu = TRUE;
|
||||
|
||||
if (!copy_value(arg->Value, &settings->PreconnectionBlob))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "pcid")
|
||||
@ -2818,25 +2823,25 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "tls-ciphers")
|
||||
{
|
||||
const char* ciphers = NULL;
|
||||
if (!arg->Value)
|
||||
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
|
||||
free(settings->AllowedTlsCiphers);
|
||||
|
||||
if (strcmp(arg->Value, "netmon") == 0)
|
||||
{
|
||||
if (!(settings->AllowedTlsCiphers = _strdup("ALL:!ECDH")))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
ciphers = "ALL:!ECDH";
|
||||
}
|
||||
else if (strcmp(arg->Value, "ma") == 0)
|
||||
{
|
||||
if (!(settings->AllowedTlsCiphers = _strdup("AES128-SHA")))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
ciphers = "AES128-SHA";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(settings->AllowedTlsCiphers = _strdup(arg->Value)))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
ciphers = arg->Value;
|
||||
}
|
||||
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_AllowedTlsCiphers, ciphers))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "tls-seclevel")
|
||||
{
|
||||
@ -2875,7 +2880,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
else if (_strnicmp(name, cur, sizeof(name)) == 0)
|
||||
{
|
||||
const char* val = &cur[sizeof(name)];
|
||||
if (!copy_value(val, &settings->CertificateName))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_CertificateName, val))
|
||||
rc = COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
else if (_strnicmp(fingerprints, cur, sizeof(fingerprints)) == 0)
|
||||
@ -2894,7 +2899,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "cert-name")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->CertificateName))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_CertificateName, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "cert-ignore")
|
||||
@ -3106,12 +3111,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "wm-class")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->WmClass))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_WmClass, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "play-rfx")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->PlayRemoteFxFile))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_PlayRemoteFxFile, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
|
||||
settings->PlayRemoteFx = TRUE;
|
||||
@ -3238,14 +3243,12 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
}
|
||||
CommandLineSwitchCase(arg, "action-script")
|
||||
{
|
||||
if (!copy_value(arg->Value, &settings->ActionScript))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ActionScript, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, RDP2TCP_DVC_CHANNEL_NAME)
|
||||
{
|
||||
free(settings->RDP2TCPArgs);
|
||||
|
||||
if (!(settings->RDP2TCPArgs = _strdup(arg->Value)))
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_RDP2TCPArgs, arg->Value))
|
||||
return COMMAND_LINE_ERROR_MEMORY;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "fipsmode")
|
||||
|
@ -54,9 +54,9 @@ static BOOL ios_ui_authenticate_raw(freerdp *instance, char **username, char **p
|
||||
free(*password);
|
||||
free(*domain);
|
||||
// set values back
|
||||
*username = strdup([[params objectForKey:@"username"] UTF8String]);
|
||||
*password = strdup([[params objectForKey:@"password"] UTF8String]);
|
||||
*domain = strdup([[params objectForKey:@"domain"] UTF8String]);
|
||||
*username = _strdup([[params objectForKey:@"username"] UTF8String]);
|
||||
*password = _strdup([[params objectForKey:@"password"] UTF8String]);
|
||||
*domain = _strdup([[params objectForKey:@"domain"] UTF8String]);
|
||||
|
||||
if (!(*username) || !(*password) || !(*domain))
|
||||
{
|
||||
|
@ -493,10 +493,8 @@ static BOOL rdp_client_redirect_try_fqdn(rdpSettings* settings)
|
||||
if (settings->GatewayEnabled ||
|
||||
rdp_client_redirect_resolvable(settings->RedirectionTargetFQDN))
|
||||
{
|
||||
free(settings->ServerHostname);
|
||||
settings->ServerHostname = _strdup(settings->RedirectionTargetFQDN);
|
||||
|
||||
if (!settings->ServerHostname)
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname,
|
||||
settings->RedirectionTargetFQDN))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -510,10 +508,8 @@ static BOOL rdp_client_redirect_try_ip(rdpSettings* settings)
|
||||
{
|
||||
if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS)
|
||||
{
|
||||
free(settings->ServerHostname);
|
||||
settings->ServerHostname = _strdup(settings->TargetNetAddress);
|
||||
|
||||
if (!settings->ServerHostname)
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname,
|
||||
settings->TargetNetAddress))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
@ -529,10 +525,8 @@ static BOOL rdp_client_redirect_try_netbios(rdpSettings* settings)
|
||||
if (settings->GatewayEnabled ||
|
||||
rdp_client_redirect_resolvable(settings->RedirectionTargetNetBiosName))
|
||||
{
|
||||
free(settings->ServerHostname);
|
||||
settings->ServerHostname = _strdup(settings->RedirectionTargetNetBiosName);
|
||||
|
||||
if (!settings->ServerHostname)
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname,
|
||||
settings->RedirectionTargetNetBiosName))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
@ -333,8 +333,8 @@ static void* mf_peer_main_loop(void* arg)
|
||||
}
|
||||
|
||||
/* Initialize the real server settings here */
|
||||
client->settings->CertificateFile = _strdup("server.crt");
|
||||
client->settings->PrivateKeyFile = _strdup("server.key");
|
||||
freerdp_settings_set_string(client->settings, FreeRDP_CertificateFile, "server.crt");
|
||||
freerdp_settings_set_string(client->settings, FreeRDP_PrivateKeyFile, "server.key");
|
||||
|
||||
if (!client->settings->CertificateFile || !client->settings->PrivateKeyFile)
|
||||
{
|
||||
|
@ -211,18 +211,14 @@ static BOOL wf_peer_read_settings(freerdp_peer* client)
|
||||
if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("CertificateFile"),
|
||||
&(client->settings->CertificateFile)))
|
||||
{
|
||||
client->settings->CertificateFile = _strdup("server.crt");
|
||||
|
||||
if (!client->settings->CertificateFile)
|
||||
if (!freerdp_settings_set_string(client->settings, FreeRDP_CertificateFile, "server.crt"))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("PrivateKeyFile"),
|
||||
&(client->settings->PrivateKeyFile)))
|
||||
{
|
||||
client->settings->PrivateKeyFile = _strdup("server.key");
|
||||
|
||||
if (!client->settings->PrivateKeyFile)
|
||||
if (!freerdp_settings_set_string(client->settings, FreeRDP_PrivateKeyFile, "server.key"))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -159,8 +159,7 @@ static BOOL pf_server_get_target_info(rdpContext* context, rdpSettings* settings
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
settings->ServerHostname = _strdup(ev.target_address);
|
||||
if (!settings->ServerHostname)
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname, ev.target_address))
|
||||
{
|
||||
PROXY_LOG_ERR(TAG, ps, "strdup failed!");
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user