mirror of https://github.com/FreeRDP/FreeRDP
Fixed issues with settings clone
This commit is contained in:
parent
29af8a45b6
commit
40ae6731c9
|
@ -129,6 +129,7 @@ typedef enum
|
|||
/* Early Capability Flags (Server to Client) */
|
||||
#define RNS_UD_SC_EDGE_ACTIONS_SUPPORTED 0x00000001
|
||||
#define RNS_UD_SC_DYNAMIC_DST_SUPPORTED 0x00000002
|
||||
#define RNS_UD_SC_EDGE_ACTIONS_SUPPORTED_V2 0x00000004
|
||||
|
||||
/* Cluster Information Flags */
|
||||
#define REDIRECTION_SUPPORTED 0x00000001
|
||||
|
@ -1710,6 +1711,8 @@ extern "C"
|
|||
#endif
|
||||
|
||||
FREERDP_API void freerdp_dynamic_channel_collection_free(rdpSettings* settings);
|
||||
FREERDP_API void freerdp_capability_buffer_free(rdpSettings* settings);
|
||||
FREERDP_API BOOL freerdp_capability_buffer_copy(rdpSettings* settings, const rdpSettings* src);
|
||||
|
||||
FREERDP_API void freerdp_target_net_addresses_free(rdpSettings* settings);
|
||||
FREERDP_API BOOL freerdp_target_net_addresses_copy(rdpSettings* settings, char** addresses,
|
||||
|
|
|
@ -816,15 +816,39 @@ void freerdp_dynamic_channel_collection_free(rdpSettings* settings)
|
|||
freerdp_settings_set_uint32(settings, FreeRDP_DynamicChannelCount, 0);
|
||||
}
|
||||
|
||||
void freerdp_capability_buffer_free(rdpSettings* settings)
|
||||
{
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
settings->ReceivedCapabilitiesSize = 0;
|
||||
|
||||
free(settings->ReceivedCapabilities);
|
||||
settings->ReceivedCapabilities = NULL;
|
||||
}
|
||||
|
||||
BOOL freerdp_capability_buffer_copy(rdpSettings* settings, const rdpSettings* src)
|
||||
{
|
||||
WINPR_ASSERT(settings);
|
||||
WINPR_ASSERT(src);
|
||||
|
||||
if (!freerdp_capability_buffer_allocate(settings, src->ReceivedCapabilitiesSize))
|
||||
return FALSE;
|
||||
|
||||
for (UINT32 x = 0; x < src->ReceivedCapabilitiesSize; x++)
|
||||
{
|
||||
WINPR_ASSERT(settings->ReceivedCapabilities);
|
||||
settings->ReceivedCapabilities[x] = src->ReceivedCapabilities[x];
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void freerdp_target_net_addresses_free(rdpSettings* settings)
|
||||
{
|
||||
UINT32 index;
|
||||
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
if (settings->TargetNetAddresses)
|
||||
{
|
||||
for (index = 0; index < settings->TargetNetAddressCount; index++)
|
||||
for (UINT32 index = 0; index < settings->TargetNetAddressCount; index++)
|
||||
free(settings->TargetNetAddresses[index]);
|
||||
}
|
||||
|
||||
|
@ -1260,11 +1284,9 @@ BOOL freerdp_settings_set_pointer_len(rdpSettings* settings, size_t id, const vo
|
|||
"FreeRDP_ChannelDefArray::len expected to be >= %" PRIu32
|
||||
", but have %" PRIu32,
|
||||
CHANNEL_MAX_COUNT, len);
|
||||
if (!freerdp_settings_set_pointer_len_(settings, FreeRDP_ChannelDefArray,
|
||||
FreeRDP_ChannelDefArraySize, data, len,
|
||||
sizeof(CHANNEL_DEF)))
|
||||
return FALSE;
|
||||
return freerdp_settings_set_uint32(settings, FreeRDP_ChannelCount, len);
|
||||
return freerdp_settings_set_pointer_len_(settings, FreeRDP_ChannelDefArray,
|
||||
FreeRDP_ChannelDefArraySize, data, len,
|
||||
sizeof(CHANNEL_DEF));
|
||||
case FreeRDP_MonitorDefArray:
|
||||
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_MonitorDefArraySize,
|
||||
data, len, sizeof(rdpMonitor));
|
||||
|
@ -1312,6 +1334,10 @@ BOOL freerdp_settings_set_pointer_len(rdpSettings* settings, size_t id, const vo
|
|||
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_DynamicChannelArraySize,
|
||||
data, len, sizeof(ADDIN_ARGV*));
|
||||
case FreeRDP_ReceivedCapabilities:
|
||||
if (data == NULL)
|
||||
freerdp_capability_buffer_free(settings);
|
||||
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_ReceivedCapabilitiesSize,
|
||||
data, len, sizeof(char));
|
||||
case FreeRDP_OrderSupport:
|
||||
return freerdp_settings_set_pointer_len_(settings, id, -1, data, len, sizeof(char));
|
||||
|
||||
|
|
|
@ -304,7 +304,8 @@ UINT freerdp_channels_attach(freerdp* instance)
|
|||
|
||||
channels = instance->context->channels;
|
||||
hostname = freerdp_settings_get_string(instance->context->settings, FreeRDP_ServerHostname);
|
||||
hostnameLength = strlen(hostname);
|
||||
WINPR_ASSERT(hostname);
|
||||
hostnameLength = strnlen(hostname, MAX_PATH);
|
||||
|
||||
for (index = 0; index < channels->clientDataCount; index++)
|
||||
{
|
||||
|
@ -367,7 +368,8 @@ UINT freerdp_channels_detach(freerdp* instance)
|
|||
|
||||
WINPR_ASSERT(context->settings);
|
||||
hostname = freerdp_settings_get_string(context->settings, FreeRDP_ServerHostname);
|
||||
hostnameLength = strlen(hostname);
|
||||
WINPR_ASSERT(hostname);
|
||||
hostnameLength = strnlen(hostname, MAX_PATH);
|
||||
|
||||
for (index = 0; index < channels->clientDataCount; index++)
|
||||
{
|
||||
|
@ -430,7 +432,8 @@ UINT freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance)
|
|||
|
||||
channels->connected = TRUE;
|
||||
hostname = freerdp_settings_get_string(instance->context->settings, FreeRDP_ServerHostname);
|
||||
hostnameLength = strlen(hostname);
|
||||
WINPR_ASSERT(hostname);
|
||||
hostnameLength = strnlen(hostname, MAX_PATH);
|
||||
|
||||
for (index = 0; index < channels->clientDataCount; index++)
|
||||
{
|
||||
|
|
|
@ -304,12 +304,31 @@ BOOL freerdp_settings_set_default_order_support(rdpSettings* settings)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_capability_buffer_allocate(rdpSettings* settings, UINT32 count)
|
||||
{
|
||||
void* tmp;
|
||||
WINPR_ASSERT(settings);
|
||||
WINPR_ASSERT(count > 0);
|
||||
WINPR_ASSERT(count == 32);
|
||||
|
||||
freerdp_capability_buffer_free(settings);
|
||||
WINPR_ASSERT(settings->ReceivedCapabilitiesSize == 0);
|
||||
|
||||
settings->ReceivedCapabilitiesSize = count;
|
||||
tmp = realloc(settings->ReceivedCapabilities, count * sizeof(BYTE));
|
||||
if (!tmp)
|
||||
return FALSE;
|
||||
memset(tmp, 0, count * sizeof(BYTE));
|
||||
settings->ReceivedCapabilities = tmp;
|
||||
|
||||
return settings->ReceivedCapabilities != NULL;
|
||||
}
|
||||
|
||||
rdpSettings* freerdp_settings_new(DWORD flags)
|
||||
{
|
||||
size_t x;
|
||||
char* base;
|
||||
rdpSettings* settings;
|
||||
settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
|
||||
rdpSettings* settings = (rdpSettings*)calloc(1, sizeof(rdpSettings));
|
||||
|
||||
if (!settings)
|
||||
return NULL;
|
||||
|
@ -387,32 +406,31 @@ rdpSettings* freerdp_settings_new(DWORD flags)
|
|||
!freerdp_settings_set_bool(settings, FreeRDP_DisableCredentialsDelegation, FALSE) ||
|
||||
!freerdp_settings_set_uint32(settings, FreeRDP_AuthenticationLevel, 2) ||
|
||||
!freerdp_settings_set_uint32(settings, FreeRDP_ChannelCount, 0) ||
|
||||
!freerdp_settings_set_uint32(settings, FreeRDP_ChannelDefArraySize, 32) ||
|
||||
!freerdp_settings_set_bool(settings, FreeRDP_CertificateUseKnownHosts, TRUE) ||
|
||||
!freerdp_settings_set_bool(settings, FreeRDP_CertificateCallbackPreferPEM, FALSE) ||
|
||||
!freerdp_settings_set_uint32(settings, FreeRDP_KeySpec, AT_KEYEXCHANGE))
|
||||
goto out_fail;
|
||||
|
||||
settings->ChannelDefArray = (CHANNEL_DEF*)calloc(
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize), sizeof(CHANNEL_DEF));
|
||||
|
||||
if (!settings->ChannelDefArray)
|
||||
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_ChannelDefArray, NULL,
|
||||
CHANNEL_MAX_COUNT))
|
||||
goto out_fail;
|
||||
|
||||
freerdp_settings_set_bool(settings, FreeRDP_SupportMonitorLayoutPdu, FALSE);
|
||||
freerdp_settings_set_uint32(settings, FreeRDP_MonitorCount, 0);
|
||||
freerdp_settings_set_uint32(settings, FreeRDP_MonitorDefArraySize, 32);
|
||||
settings->MonitorDefArray = (rdpMonitor*)calloc(
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_MonitorDefArraySize), sizeof(rdpMonitor));
|
||||
|
||||
if (!settings->MonitorDefArray)
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportMonitorLayoutPdu, FALSE))
|
||||
goto out_fail;
|
||||
|
||||
freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, 0);
|
||||
freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, 0);
|
||||
settings->MonitorIds = (UINT32*)calloc(16, sizeof(UINT32));
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorCount, 0))
|
||||
goto out_fail;
|
||||
|
||||
if (!settings->MonitorIds)
|
||||
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorDefArray, NULL, 32))
|
||||
goto out_fail;
|
||||
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftX, 0))
|
||||
goto out_fail;
|
||||
|
||||
if (!freerdp_settings_set_uint32(settings, FreeRDP_MonitorLocalShiftY, 0))
|
||||
goto out_fail;
|
||||
|
||||
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_MonitorIds, NULL, 16))
|
||||
goto out_fail;
|
||||
|
||||
if (!settings_get_computer_name(settings))
|
||||
|
@ -421,9 +439,7 @@ rdpSettings* freerdp_settings_new(DWORD flags)
|
|||
if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerCertificate, NULL, 1))
|
||||
goto out_fail;
|
||||
|
||||
settings->ReceivedCapabilities = calloc(1, 32);
|
||||
|
||||
if (!settings->ReceivedCapabilities)
|
||||
if (!freerdp_capability_buffer_allocate(settings, 32))
|
||||
goto out_fail;
|
||||
|
||||
{
|
||||
|
@ -638,8 +654,7 @@ rdpSettings* freerdp_settings_new(DWORD flags)
|
|||
BOOL res;
|
||||
size_t i;
|
||||
char* cpath;
|
||||
char product[sizeof(FREERDP_PRODUCT_STRING)];
|
||||
memset(product, 0, sizeof(product));
|
||||
char product[sizeof(FREERDP_PRODUCT_STRING)] = { 0 };
|
||||
|
||||
for (i = 0; i < sizeof(product); i++)
|
||||
product[i] = tolower(FREERDP_PRODUCT_STRING[i]);
|
||||
|
@ -672,6 +687,18 @@ rdpSettings* freerdp_settings_new(DWORD flags)
|
|||
if (!freerdp_settings_set_default_order_support(settings))
|
||||
goto out_fail;
|
||||
|
||||
{
|
||||
BOOL enable = freerdp_settings_get_bool(settings, FreeRDP_ServerMode);
|
||||
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportDynamicTimeZone, enable))
|
||||
goto out_fail;
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, enable))
|
||||
goto out_fail;
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportStatusInfoPdu, enable))
|
||||
goto out_fail;
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_SupportErrorInfoPdu, enable))
|
||||
goto out_fail;
|
||||
}
|
||||
return settings;
|
||||
out_fail:
|
||||
freerdp_settings_free(settings);
|
||||
|
@ -685,6 +712,7 @@ static void freerdp_settings_free_internal(rdpSettings* settings)
|
|||
freerdp_static_channel_collection_free(settings);
|
||||
freerdp_dynamic_channel_collection_free(settings);
|
||||
|
||||
freerdp_capability_buffer_free(settings);
|
||||
/* Extensions */
|
||||
free(settings->XSelectionAtom);
|
||||
settings->XSelectionAtom = NULL;
|
||||
|
@ -734,17 +762,25 @@ static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSe
|
|||
|
||||
if (settings->RdpServerCertificate)
|
||||
{
|
||||
_settings->RdpServerCertificate = certificate_clone(settings->RdpServerCertificate);
|
||||
|
||||
if (!_settings->RdpServerCertificate)
|
||||
rdpCertificate* cert = certificate_clone(settings->RdpServerCertificate);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerCertificate, cert, 1))
|
||||
goto out_fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerCertificate, NULL, 0))
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
if (settings->RdpServerRsaKey)
|
||||
{
|
||||
_settings->RdpServerRsaKey = key_clone(settings->RdpServerRsaKey);
|
||||
|
||||
if (!_settings->RdpServerRsaKey)
|
||||
rdpRsaKey* key = key_clone(settings->RdpServerRsaKey);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerRsaKey, key, 1))
|
||||
goto out_fail;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RdpServerRsaKey, NULL, 0))
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
|
@ -756,51 +792,24 @@ static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSe
|
|||
freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize)))
|
||||
goto out_fail;
|
||||
|
||||
if (freerdp_settings_get_uint32(_settings, FreeRDP_ChannelDefArraySize) > 0)
|
||||
{
|
||||
_settings->ChannelDefArray =
|
||||
(CHANNEL_DEF*)calloc(freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize),
|
||||
sizeof(CHANNEL_DEF));
|
||||
|
||||
if (!_settings->ChannelDefArray)
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->ChannelDefArray, settings->ChannelDefArray,
|
||||
sizeof(CHANNEL_DEF) *
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize));
|
||||
}
|
||||
else
|
||||
_settings->ChannelDefArray = NULL;
|
||||
|
||||
freerdp_settings_set_uint32(_settings, FreeRDP_MonitorCount,
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount));
|
||||
freerdp_settings_set_uint32(_settings, FreeRDP_MonitorDefArraySize,
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_MonitorDefArraySize));
|
||||
|
||||
if (freerdp_settings_get_uint32(_settings, FreeRDP_MonitorDefArraySize) > 0)
|
||||
{
|
||||
_settings->MonitorDefArray = (rdpMonitor*)calloc(
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_MonitorDefArraySize), sizeof(rdpMonitor));
|
||||
|
||||
if (!_settings->MonitorDefArray)
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->MonitorDefArray, settings->MonitorDefArray,
|
||||
sizeof(rdpMonitor) *
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_MonitorDefArraySize));
|
||||
}
|
||||
else
|
||||
_settings->MonitorDefArray = NULL;
|
||||
|
||||
_settings->MonitorIds = (UINT32*)calloc(16, sizeof(UINT32));
|
||||
|
||||
if (!_settings->MonitorIds)
|
||||
const UINT32 defArraySize = freerdp_settings_get_uint32(settings, FreeRDP_ChannelDefArraySize);
|
||||
const CHANNEL_DEF* defArray = freerdp_settings_get_pointer(settings, FreeRDP_ChannelDefArray);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_ChannelDefArray, defArray,
|
||||
defArraySize))
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->MonitorIds, settings->MonitorIds, 16 * sizeof(UINT32));
|
||||
_settings->ReceivedCapabilities = malloc(32);
|
||||
const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_MonitorDefArraySize);
|
||||
const rdpMonitor* monitors = freerdp_settings_get_pointer(settings, FreeRDP_MonitorDefArray);
|
||||
|
||||
if (!_settings->ReceivedCapabilities)
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_MonitorDefArray, monitors, count))
|
||||
goto out_fail;
|
||||
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_MonitorIds, NULL, 16))
|
||||
goto out_fail;
|
||||
|
||||
const UINT32 monitorIdSize = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds);
|
||||
const UINT32* monitorIds = freerdp_settings_get_pointer(settings, FreeRDP_MonitorIds);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_MonitorIds, monitorIds, monitorIdSize))
|
||||
goto out_fail;
|
||||
|
||||
_settings->OrderSupport = malloc(32);
|
||||
|
@ -808,33 +817,31 @@ static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSe
|
|||
if (!_settings->OrderSupport)
|
||||
goto out_fail;
|
||||
|
||||
if (!_settings->ReceivedCapabilities || !_settings->OrderSupport)
|
||||
if (!freerdp_capability_buffer_copy(_settings, settings))
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->ReceivedCapabilities, settings->ReceivedCapabilities, 32);
|
||||
CopyMemory(_settings->OrderSupport, settings->OrderSupport, 32);
|
||||
|
||||
_settings->BitmapCacheV2CellInfo =
|
||||
(BITMAP_CACHE_V2_CELL_INFO*)malloc(sizeof(BITMAP_CACHE_V2_CELL_INFO) * 6);
|
||||
|
||||
if (!_settings->BitmapCacheV2CellInfo)
|
||||
const UINT32 cellInfoSize =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_BitmapCacheV2NumCells);
|
||||
const BITMAP_CACHE_V2_CELL_INFO* cellInfo =
|
||||
freerdp_settings_get_pointer(settings, FreeRDP_BitmapCacheV2CellInfo);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_BitmapCacheV2CellInfo, cellInfo,
|
||||
cellInfoSize))
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->BitmapCacheV2CellInfo, settings->BitmapCacheV2CellInfo,
|
||||
sizeof(BITMAP_CACHE_V2_CELL_INFO) * 6);
|
||||
_settings->GlyphCache = malloc(sizeof(GLYPH_CACHE_DEFINITION) * 10);
|
||||
|
||||
if (!_settings->GlyphCache)
|
||||
const UINT32 glyphCacheCount = 10;
|
||||
const GLYPH_CACHE_DEFINITION* glyphCache =
|
||||
freerdp_settings_get_pointer(settings, FreeRDP_GlyphCache);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_GlyphCache, glyphCache,
|
||||
glyphCacheCount))
|
||||
goto out_fail;
|
||||
|
||||
_settings->FragCache = malloc(sizeof(GLYPH_CACHE_DEFINITION));
|
||||
|
||||
if (!_settings->FragCache)
|
||||
const UINT32 fragCacheCount = 1;
|
||||
const GLYPH_CACHE_DEFINITION* fragCache =
|
||||
freerdp_settings_get_pointer(settings, FreeRDP_FragCache);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_FragCache, fragCache, fragCacheCount))
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->GlyphCache, settings->GlyphCache, sizeof(GLYPH_CACHE_DEFINITION) * 10);
|
||||
CopyMemory(_settings->FragCache, settings->FragCache, sizeof(GLYPH_CACHE_DEFINITION));
|
||||
|
||||
if (!freerdp_settings_set_pointer_len(
|
||||
_settings, FreeRDP_ClientAutoReconnectCookie,
|
||||
freerdp_settings_get_pointer(settings, FreeRDP_ClientAutoReconnectCookie), 1))
|
||||
|
@ -844,44 +851,29 @@ static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSe
|
|||
freerdp_settings_get_pointer(settings, FreeRDP_ServerAutoReconnectCookie), 1))
|
||||
goto out_fail;
|
||||
|
||||
_settings->ClientTimeZone = (LPTIME_ZONE_INFORMATION)malloc(sizeof(TIME_ZONE_INFORMATION));
|
||||
|
||||
if (!_settings->ClientTimeZone)
|
||||
const TIME_ZONE_INFORMATION* tz =
|
||||
freerdp_settings_get_pointer(settings, FreeRDP_ClientTimeZone);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_ClientTimeZone, tz, 1))
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->ClientTimeZone, settings->ClientTimeZone, sizeof(TIME_ZONE_INFORMATION));
|
||||
|
||||
if (!freerdp_settings_set_uint32(
|
||||
_settings, FreeRDP_RedirectionPasswordLength,
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_RedirectionPasswordLength)))
|
||||
goto out_fail;
|
||||
if (freerdp_settings_get_uint32(settings, FreeRDP_RedirectionPasswordLength) > 0)
|
||||
{
|
||||
_settings->RedirectionPassword =
|
||||
malloc(freerdp_settings_get_uint32(_settings, FreeRDP_RedirectionPasswordLength));
|
||||
if (!_settings->RedirectionPassword)
|
||||
{
|
||||
freerdp_settings_set_uint32(_settings, FreeRDP_RedirectionPasswordLength, 0);
|
||||
goto out_fail;
|
||||
}
|
||||
const UINT32 redirectionPasswordLength =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_RedirectionPasswordLength);
|
||||
const BYTE* pwd = freerdp_settings_get_pointer(settings, FreeRDP_RedirectionPassword);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RedirectionPassword, pwd,
|
||||
redirectionPasswordLength))
|
||||
goto out_fail;
|
||||
|
||||
CopyMemory(_settings->RedirectionPassword, settings->RedirectionPassword,
|
||||
freerdp_settings_get_uint32(_settings, FreeRDP_RedirectionPasswordLength));
|
||||
}
|
||||
|
||||
_settings->RedirectionTsvUrlLength = settings->RedirectionTsvUrlLength;
|
||||
if (settings->RedirectionTsvUrlLength > 0)
|
||||
{
|
||||
_settings->RedirectionTsvUrl = malloc(_settings->RedirectionTsvUrlLength);
|
||||
if (!_settings->RedirectionTsvUrl)
|
||||
{
|
||||
_settings->RedirectionTsvUrlLength = 0;
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
CopyMemory(_settings->RedirectionTsvUrl, settings->RedirectionTsvUrl,
|
||||
_settings->RedirectionTsvUrlLength);
|
||||
}
|
||||
const UINT32 RedirectionTsvUrlLength =
|
||||
freerdp_settings_get_uint32(settings, FreeRDP_RedirectionTsvUrlLength);
|
||||
const BYTE* RedirectionTsvUrl =
|
||||
freerdp_settings_get_pointer(settings, FreeRDP_RedirectionTsvUrl);
|
||||
if (!freerdp_settings_set_pointer_len(_settings, FreeRDP_RedirectionTsvUrl, RedirectionTsvUrl,
|
||||
RedirectionTsvUrlLength))
|
||||
goto out_fail;
|
||||
|
||||
freerdp_settings_set_uint32(
|
||||
_settings, FreeRDP_TargetNetAddressCount,
|
||||
|
|
|
@ -44,5 +44,6 @@ FREERDP_LOCAL BOOL freerdp_settings_clone_keys(rdpSettings* dst, const rdpSettin
|
|||
FREERDP_LOCAL void freerdp_settings_free_keys(rdpSettings* dst, BOOL cleanup);
|
||||
FREERDP_LOCAL BOOL freerdp_settings_set_string_(rdpSettings* settings, size_t id, const char* val,
|
||||
size_t len, BOOL cleanup);
|
||||
FREERDP_LOCAL BOOL freerdp_capability_buffer_allocate(rdpSettings* settings, UINT32 count);
|
||||
|
||||
#endif /* FREERDP_LIB_CORE_SETTINGS_H */
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <winpr/crypto.h>
|
||||
|
||||
#include <freerdp/settings.h>
|
||||
|
@ -5,9 +7,16 @@
|
|||
|
||||
#include "settings_property_lists.h"
|
||||
|
||||
static BOOL log_result(BOOL value, const char* fkt)
|
||||
{
|
||||
fprintf(stderr, "TestSettings [%s] returned %s\n", fkt, value ? "TRUE" : "FALSE");
|
||||
return value;
|
||||
}
|
||||
|
||||
static BOOL compare(const ADDIN_ARGV* got, const ADDIN_ARGV* expect)
|
||||
{
|
||||
int x;
|
||||
BOOL rc = TRUE;
|
||||
if (!got && expect)
|
||||
return FALSE;
|
||||
if (got && !expect)
|
||||
|
@ -18,9 +27,9 @@ static BOOL compare(const ADDIN_ARGV* got, const ADDIN_ARGV* expect)
|
|||
for (x = 0; x < expect->argc; x++)
|
||||
{
|
||||
if (strcmp(got->argv[x], expect->argv[x]) != 0)
|
||||
return FALSE;
|
||||
rc = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL test_dyn_channels(void)
|
||||
|
@ -120,7 +129,7 @@ fail:
|
|||
freerdp_settings_free(settings);
|
||||
freerdp_addin_argv_free(args1);
|
||||
freerdp_addin_argv_free(args2);
|
||||
return rc;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL test_static_channels(void)
|
||||
|
@ -220,7 +229,7 @@ fail:
|
|||
freerdp_settings_free(settings);
|
||||
freerdp_addin_argv_free(args1);
|
||||
freerdp_addin_argv_free(args2);
|
||||
return rc;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL test_copy(void)
|
||||
|
@ -246,7 +255,7 @@ fail:
|
|||
freerdp_settings_free(settings);
|
||||
freerdp_settings_free(copy);
|
||||
freerdp_settings_free(modified);
|
||||
return rc;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL test_helpers(void)
|
||||
|
@ -285,7 +294,7 @@ static BOOL test_helpers(void)
|
|||
rc = TRUE;
|
||||
fail:
|
||||
freerdp_settings_free(settings);
|
||||
return rc;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL format_uint(char* buffer, size_t size, UINT64 value, UINT16 intType, UINT64 max)
|
||||
|
@ -428,51 +437,92 @@ static BOOL format_bool(char* buffer, size_t size, UINT16 intType)
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL check_key_helpers(size_t key)
|
||||
static BOOL check_key_helpers(size_t key, const char* stype)
|
||||
{
|
||||
int test_rounds = 100;
|
||||
BOOL res = FALSE;
|
||||
rdpSettings* settings = NULL;
|
||||
SSIZE_T rc, tkey, type;
|
||||
|
||||
size_t x;
|
||||
const size_t clear_keys[] = { FreeRDP_RdpServerCertificate,
|
||||
FreeRDP_RdpServerRsaKey,
|
||||
FreeRDP_RedirectionPassword,
|
||||
FreeRDP_RedirectionTsvUrl,
|
||||
FreeRDP_LoadBalanceInfo,
|
||||
FreeRDP_ServerRandom,
|
||||
FreeRDP_ClientRandom,
|
||||
FreeRDP_ServerCertificate,
|
||||
FreeRDP_TargetNetAddresses,
|
||||
FreeRDP_ReceivedCapabilities,
|
||||
FreeRDP_TargetNetPorts,
|
||||
FreeRDP_DeviceArray,
|
||||
FreeRDP_ChannelDefArray,
|
||||
FreeRDP_MonitorDefArray,
|
||||
FreeRDP_ClientAutoReconnectCookie,
|
||||
FreeRDP_ServerAutoReconnectCookie,
|
||||
FreeRDP_ClientTimeZone,
|
||||
FreeRDP_BitmapCacheV2CellInfo,
|
||||
FreeRDP_GlyphCache,
|
||||
FreeRDP_FragCache,
|
||||
FreeRDP_StaticChannelArray,
|
||||
FreeRDP_DynamicChannelArray,
|
||||
FreeRDP_ReceivedCapabilities,
|
||||
FreeRDP_OrderSupport,
|
||||
FreeRDP_MonitorIds };
|
||||
const char* name = freerdp_settings_get_name_for_key(key);
|
||||
if (!name)
|
||||
{
|
||||
printf("missing name for key %" PRIuz "\n", key);
|
||||
printf("[%s] missing name for key %" PRIuz "\n", stype, key);
|
||||
return FALSE;
|
||||
}
|
||||
tkey = freerdp_settings_get_key_for_name(name);
|
||||
if (tkey < 0)
|
||||
{
|
||||
printf("missing reverse name for key %s [%" PRIuz "]\n", name, key);
|
||||
printf("[%s] missing reverse name for key %s [%" PRIuz "]\n", stype, name, key);
|
||||
return FALSE;
|
||||
}
|
||||
if ((size_t)tkey != key)
|
||||
{
|
||||
printf("mismatch reverse name for key %s [%" PRIuz "]: %" PRIdz "\n", name, key, tkey);
|
||||
printf("[%s] mismatch reverse name for key %s [%" PRIuz "]: %" PRIdz "\n", stype, name, key,
|
||||
tkey);
|
||||
return FALSE;
|
||||
}
|
||||
type = freerdp_settings_get_type_for_name(name);
|
||||
if (type < 0)
|
||||
{
|
||||
printf("missing reverse type for key %s [%" PRIuz "]\n", name, key);
|
||||
printf("[%s] missing reverse type for key %s [%" PRIuz "]\n", stype, name, key);
|
||||
return FALSE;
|
||||
}
|
||||
rc = freerdp_settings_get_type_for_key(key);
|
||||
if (rc < 0)
|
||||
{
|
||||
printf("missing reverse name for key %s [%" PRIuz "]\n", name, key);
|
||||
printf("[%s] missing reverse name for key %s [%" PRIuz "]\n", stype, name, key);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (rc != type)
|
||||
{
|
||||
printf("mismatch reverse type for key %s [%" PRIuz "]: %" PRIdz " <--> %" PRIdz "\n", name,
|
||||
key, rc, type);
|
||||
printf("[%s] mismatch reverse type for key %s [%" PRIuz "]: %" PRIdz " <--> %" PRIdz "\n",
|
||||
stype, name, key, rc, type);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
settings = freerdp_settings_new(0);
|
||||
if (!settings)
|
||||
{
|
||||
printf("[%s] freerdp_settings_new failed\n", stype);
|
||||
goto fail;
|
||||
}
|
||||
for (x = 0; x < ARRAYSIZE(clear_keys); x++)
|
||||
{
|
||||
const size_t id = clear_keys[x];
|
||||
const char* foo = freerdp_settings_get_name_for_key(id);
|
||||
if (!freerdp_settings_set_pointer_len(settings, id, NULL, 0))
|
||||
{
|
||||
printf("[%s] freerdp_settings_set_pointer_len(%s, NULL, 0) failed\n", stype, foo);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
do
|
||||
{
|
||||
UINT16 intEntryType = 0;
|
||||
|
@ -527,21 +577,25 @@ static BOOL check_key_helpers(size_t key)
|
|||
break;
|
||||
|
||||
default:
|
||||
printf("invalid type for key %s [%" PRIuz "]: %" PRIdz " <--> %" PRIdz "\n", name,
|
||||
key, rc, type);
|
||||
printf("[%s] invalid type for key %s [%" PRIuz "]: %" PRIdz " <--> %" PRIdz "\n",
|
||||
stype, name, key, rc, type);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
have = freerdp_settings_set_value_for_name(settings, name, value);
|
||||
if (have != expect)
|
||||
{
|
||||
printf("[%s] have[%s] != expect[%s]\n", stype, have ? "TRUE" : "FALSE",
|
||||
expect ? "TRUE" : "FALSE");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
} while (test_rounds-- > 0);
|
||||
|
||||
res = TRUE;
|
||||
fail:
|
||||
freerdp_settings_free(settings);
|
||||
return res;
|
||||
return log_result(res, __func__);
|
||||
}
|
||||
|
||||
static BOOL check_args(const RDPDR_DEVICE* what, size_t count, const char* args[])
|
||||
|
@ -657,7 +711,7 @@ static int check_device_type_arg(UINT32 Type, size_t count, const char* args[])
|
|||
fail:
|
||||
freerdp_device_free(device);
|
||||
freerdp_device_free(clone);
|
||||
return rc;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL check_device_type(void)
|
||||
|
@ -709,20 +763,21 @@ static BOOL check_device_type(void)
|
|||
{ -3, 0x123, 3, args },
|
||||
{ -3, 0x123, 4, args },
|
||||
};
|
||||
|
||||
BOOL rc = TRUE;
|
||||
for (x = 0; x < ARRAYSIZE(tests); x++)
|
||||
{
|
||||
const struct test_entry* cur = &tests[x];
|
||||
int got = check_device_type_arg(cur->type, cur->count, cur->args);
|
||||
if (got != cur->expect)
|
||||
return FALSE;
|
||||
rc = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL check_offsets(rdpSettings* settings, size_t id, size_t min, size_t max, BOOL checkPtr)
|
||||
{
|
||||
size_t x;
|
||||
BOOL rc = TRUE;
|
||||
|
||||
WINPR_ASSERT(settings);
|
||||
|
||||
|
@ -733,9 +788,9 @@ static BOOL check_offsets(rdpSettings* settings, size_t id, size_t min, size_t m
|
|||
{
|
||||
const void* ptr = freerdp_settings_get_pointer_array(settings, id, x);
|
||||
if (!ptr && checkPtr)
|
||||
return FALSE;
|
||||
rc = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
|
||||
static BOOL test_write_offsets(rdpSettings* settings, size_t id, size_t elementSize, size_t min,
|
||||
|
@ -876,7 +931,7 @@ static BOOL test_pointer_array(void)
|
|||
|
||||
fail:
|
||||
freerdp_settings_free(settings);
|
||||
return rc;
|
||||
return log_result(rc, __func__);
|
||||
}
|
||||
int TestSettings(int argc, char* argv[])
|
||||
{
|
||||
|
@ -934,7 +989,7 @@ int TestSettings(int argc, char* argv[])
|
|||
}
|
||||
if (!freerdp_settings_set_bool(settings, key, val))
|
||||
goto fail;
|
||||
if (!check_key_helpers(key))
|
||||
if (!check_key_helpers(key, "bool"))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -954,7 +1009,7 @@ int TestSettings(int argc, char* argv[])
|
|||
}
|
||||
if (!freerdp_settings_set_int16(settings, key, val))
|
||||
goto fail;
|
||||
if (!check_key_helpers(key))
|
||||
if (!check_key_helpers(key, "int16"))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -974,7 +1029,7 @@ int TestSettings(int argc, char* argv[])
|
|||
}
|
||||
if (!freerdp_settings_set_uint16(settings, key, val))
|
||||
goto fail;
|
||||
if (!check_key_helpers(key))
|
||||
if (!check_key_helpers(key, "uint16"))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -994,7 +1049,7 @@ int TestSettings(int argc, char* argv[])
|
|||
}
|
||||
if (!freerdp_settings_set_uint32(settings, key, val))
|
||||
goto fail;
|
||||
if (!check_key_helpers(key))
|
||||
if (!check_key_helpers(key, "uint32"))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1014,7 +1069,7 @@ int TestSettings(int argc, char* argv[])
|
|||
}
|
||||
if (!freerdp_settings_set_int32(settings, key, val))
|
||||
goto fail;
|
||||
if (!check_key_helpers(key))
|
||||
if (!check_key_helpers(key, "int32"))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1089,7 @@ int TestSettings(int argc, char* argv[])
|
|||
}
|
||||
if (!freerdp_settings_set_uint64(settings, key, val))
|
||||
goto fail;
|
||||
if (!check_key_helpers(key))
|
||||
if (!check_key_helpers(key, "uint64"))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1109,7 @@ int TestSettings(int argc, char* argv[])
|
|||
}
|
||||
if (!freerdp_settings_set_int64(settings, key, val))
|
||||
goto fail;
|
||||
if (!check_key_helpers(key))
|
||||
if (!check_key_helpers(key, "int64"))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue