Fixed memory corruption that occured when writing rdpFile to disk

This commit is contained in:
Marc-André Moreau 2013-11-07 10:37:46 -05:00
parent 778c0274ea
commit d754e4f9a8
4 changed files with 21 additions and 20 deletions

View File

@ -151,7 +151,7 @@ int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings,
return status;
}
int freerdp_client_settings_write_connection_file(rdpSettings* settings, const char* filename, BOOL unicode)
int freerdp_client_settings_write_connection_file(const rdpSettings* settings, const char* filename, BOOL unicode)
{
rdpFile* file;
int status = -1;

View File

@ -532,13 +532,14 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
#define WRITE_ALL_SETTINGS TRUE
#define SETTING_MODIFIED(_settings, _field) (WRITE_ALL_SETTINGS || _settings->SettingsModified[FreeRDP_##_field])
#define SETTING_MODIFIED_SET(_target, _settings, _field) if SETTING_MODIFIED(_settings, _field) _target = _settings->_field
#define SETTING_MODIFIED_SET_STRING(_target, _settings, _field) if SETTING_MODIFIED(_settings, _field) _target = _strdup(_settings->_field)
BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, rdpSettings* settings)
BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSettings* settings)
{
SETTING_MODIFIED_SET(file->Domain, settings, Domain);
SETTING_MODIFIED_SET(file->Username, settings, Username);
SETTING_MODIFIED_SET_STRING(file->Domain, settings, Domain);
SETTING_MODIFIED_SET_STRING(file->Username, settings, Username);
SETTING_MODIFIED_SET(file->ServerPort, settings, ServerPort);
SETTING_MODIFIED_SET(file->FullAddress, settings, ServerHostname);
SETTING_MODIFIED_SET_STRING(file->FullAddress, settings, ServerHostname);
SETTING_MODIFIED_SET(file->DesktopWidth, settings, DesktopWidth);
SETTING_MODIFIED_SET(file->DesktopHeight, settings, DesktopHeight);
SETTING_MODIFIED_SET(file->SessionBpp, settings, ColorDepth);
@ -546,8 +547,8 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, rdpSettings*
SETTING_MODIFIED_SET(file->AdministrativeSession, settings, ConsoleSession);
SETTING_MODIFIED_SET(file->NegotiateSecurityLayer, settings, NegotiateSecurityLayer);
SETTING_MODIFIED_SET(file->EnableCredSSPSupport, settings, NlaSecurity);
SETTING_MODIFIED_SET(file->AlternateShell, settings, AlternateShell);
SETTING_MODIFIED_SET(file->ShellWorkingDirectory, settings, ShellWorkingDirectory);
SETTING_MODIFIED_SET_STRING(file->AlternateShell, settings, AlternateShell);
SETTING_MODIFIED_SET_STRING(file->ShellWorkingDirectory, settings, ShellWorkingDirectory);
SETTING_MODIFIED_SET(file->ConnectionType, settings, ConnectionType);
if (SETTING_MODIFIED(settings, AudioPlayback) || SETTING_MODIFIED(settings, RemoteConsoleAudio))
@ -560,17 +561,17 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, rdpSettings*
file->AudioMode = AUDIO_MODE_NONE;
}
SETTING_MODIFIED_SET(file->GatewayHostname, settings, GatewayHostname);
SETTING_MODIFIED_SET_STRING(file->GatewayHostname, settings, GatewayHostname);
SETTING_MODIFIED_SET(file->GatewayUsageMethod, settings, GatewayUsageMethod);
SETTING_MODIFIED_SET(file->PromptCredentialOnce, settings, GatewayUseSameCredentials);
SETTING_MODIFIED_SET(file->RemoteApplicationMode, settings, RemoteApplicationMode);
SETTING_MODIFIED_SET(file->RemoteApplicationProgram, settings, RemoteApplicationProgram);
SETTING_MODIFIED_SET(file->RemoteApplicationName, settings, RemoteApplicationName);
SETTING_MODIFIED_SET(file->RemoteApplicationIcon, settings, RemoteApplicationIcon);
SETTING_MODIFIED_SET(file->RemoteApplicationFile, settings, RemoteApplicationFile);
SETTING_MODIFIED_SET(file->RemoteApplicationGuid, settings, RemoteApplicationGuid);
SETTING_MODIFIED_SET(file->RemoteApplicationCmdLine, settings, RemoteApplicationCmdLine);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationProgram, settings, RemoteApplicationProgram);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationName, settings, RemoteApplicationName);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationIcon, settings, RemoteApplicationIcon);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationFile, settings, RemoteApplicationFile);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationGuid, settings, RemoteApplicationGuid);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationCmdLine, settings, RemoteApplicationCmdLine);
SETTING_MODIFIED_SET(file->SpanMonitors, settings, SpanMonitors);
SETTING_MODIFIED_SET(file->UseMultiMon, settings, UseMultimon);
@ -578,7 +579,7 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, rdpSettings*
return TRUE;
}
BOOL freerdp_client_write_rdp_file(rdpFile* file, const char* name, BOOL unicode)
BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL unicode)
{
int rc = 0;
char* buffer;
@ -656,7 +657,7 @@ if (~__rdpFile->_field) \
#define WRITE_RDP_FILE_VALUE_RETURN \
return __required_size;
size_t freerdp_client_write_rdp_file_buffer(rdpFile* file, char* buffer, size_t size)
size_t freerdp_client_write_rdp_file_buffer(const rdpFile* file, char* buffer, size_t size)
{
WRITE_RDP_FILE_DECLARE(file, buffer, size)

View File

@ -88,7 +88,7 @@ FREERDP_API HANDLE freerdp_client_get_thread(rdpContext* context);
FREERDP_API int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv);
FREERDP_API int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename);
FREERDP_API int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, BYTE* buffer, size_t size);
FREERDP_API int freerdp_client_settings_write_connection_file(rdpSettings* settings, const char* filename, BOOL unicode);
FREERDP_API int freerdp_client_settings_write_connection_file(const rdpSettings* settings, const char* filename, BOOL unicode);
#ifdef __cplusplus
}

View File

@ -145,9 +145,9 @@ FREERDP_API BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name);
FREERDP_API BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, BYTE* buffer, size_t size);
FREERDP_API BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings);
FREERDP_API BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, rdpSettings* settings);
FREERDP_API BOOL freerdp_client_write_rdp_file(rdpFile* file, const char* name, BOOL unicode);
FREERDP_API size_t freerdp_client_write_rdp_file_buffer(rdpFile* file, char* buffer, size_t size);
FREERDP_API BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSettings* settings);
FREERDP_API BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL unicode);
FREERDP_API size_t freerdp_client_write_rdp_file_buffer(const rdpFile* file, char* buffer, size_t size);
FREERDP_API rdpFile* freerdp_client_rdp_file_new(void);
FREERDP_API void freerdp_client_rdp_file_free(rdpFile* file);