misc: integrate pull request feedback

This commit is contained in:
Bernhard Miklautz 2015-06-22 18:52:13 +02:00
parent 421b74e85e
commit 06502e6a91
18 changed files with 123 additions and 158 deletions

View File

@ -36,6 +36,7 @@
#include <freerdp/locale/keyboard.h> #include <freerdp/locale/keyboard.h>
#include <freerdp/primitives.h> #include <freerdp/primitives.h>
#include <freerdp/version.h> #include <freerdp/version.h>
#include <freerdp/settings.h>
#include <android/bitmap.h> #include <android/bitmap.h>
@ -715,13 +716,20 @@ JNIEXPORT jboolean JNICALL jni_freerdp_disconnect(JNIEnv *env, jclass cls, jint
freerdp* inst = (freerdp*)instance; freerdp* inst = (freerdp*)instance;
androidContext* ctx = (androidContext*)inst->context; androidContext* ctx = (androidContext*)inst->context;
ANDROID_EVENT* event = (ANDROID_EVENT*)android_event_disconnect_new(); ANDROID_EVENT* event = (ANDROID_EVENT*)android_event_disconnect_new();
if (!event)
return JNI_FALSE;
DEBUG_ANDROID("DISCONNECT!"); DEBUG_ANDROID("DISCONNECT!");
assert(inst); assert(inst);
assert(ctx); assert(ctx);
assert(event); assert(event);
android_push_event(inst, event); if (!android_push_event(inst, event))
{
android_event_disconnect_free(event);
return JNI_FALSE;
}
WaitForSingleObject(ctx->thread, INFINITE); WaitForSingleObject(ctx->thread, INFINITE);
CloseHandle(ctx->thread); CloseHandle(ctx->thread);
@ -748,6 +756,7 @@ JNIEXPORT jboolean JNICALL jni_freerdp_set_data_directory(JNIEnv *env, jclass cl
free(settings->HomePath); free(settings->HomePath);
free(settings->ConfigPath); free(settings->ConfigPath);
settings->HomePath = settings->ConfigPath = NULL;
int config_dir_len = strlen(directory) + 10; /* +9 chars for /.freerdp and +1 for \0 */ int config_dir_len = strlen(directory) + 10; /* +9 chars for /.freerdp and +1 for \0 */
char* config_dir_buf = (char*)malloc(config_dir_len); char* config_dir_buf = (char*)malloc(config_dir_len);
@ -1019,8 +1028,6 @@ out_fail:
JNIEXPORT jboolean JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env, JNIEXPORT jboolean JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env,
jclass cls, jint instance, jint redirect) jclass cls, jint instance, jint redirect)
{ {
char** p;
int count = 1;
freerdp* inst = (freerdp*)instance; freerdp* inst = (freerdp*)instance;
rdpSettings * settings = inst->settings; rdpSettings * settings = inst->settings;
@ -1031,16 +1038,10 @@ JNIEXPORT jboolean JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env,
if (settings->AudioPlayback) if (settings->AudioPlayback)
{ {
int ret; int ret;
p = malloc(sizeof(char*)); char* p[1] = {"rdpsnd"};
if (!p) int count = 1;
{
settings->AudioPlayback = FALSE;
return JNI_FALSE;
}
p[0] = "rdpsnd";
ret = freerdp_client_add_static_channel(settings, count, p); ret = freerdp_client_add_static_channel(settings, count, p);
free(p);
if(ret == -1) if(ret == -1)
return JNI_FALSE; return JNI_FALSE;
@ -1052,8 +1053,6 @@ JNIEXPORT jboolean JNICALL jni_freerdp_set_sound_redirection(JNIEnv *env,
JNIEXPORT jboolean JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env, JNIEXPORT jboolean JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env,
jclass cls, jint instance, jboolean enable) jclass cls, jint instance, jboolean enable)
{ {
char** p;
int count = 1;
freerdp* inst = (freerdp*)instance; freerdp* inst = (freerdp*)instance;
rdpSettings * settings = inst->settings; rdpSettings * settings = inst->settings;
@ -1063,16 +1062,10 @@ JNIEXPORT jboolean JNICALL jni_freerdp_set_microphone_redirection(JNIEnv *env,
if (enable) if (enable)
{ {
int ret; int ret;
p = malloc(sizeof(char*)); char* p[1] = {"audin"};
if (!p) int count = 1;
{
settings->AudioCapture = FALSE;
return JNI_FALSE;
}
p[0] = "audin";
ret = freerdp_client_add_dynamic_channel(settings, count, p); ret = freerdp_client_add_dynamic_channel(settings, count, p);
free(p);
if (ret == -1) if (ret == -1)
return JNI_FALSE; return JNI_FALSE;

View File

@ -79,6 +79,8 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if (!context->argv[index]) if (!context->argv[index])
{ {
ret = 1; ret = 1;
for (--index; index > = 0; --index)
free(context->argv[index]);
free(context->argv); free(context->argv);
context->argv = NULL; context->argv = NULL;
goto out; goto out;

View File

@ -61,7 +61,7 @@ static WCHAR CR_LF_STR_W[] = { '\r', '\n', '\0' };
static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int value, int index) static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int value, int index)
{ {
int bStandard = 1; int standard = 1;
#ifdef DEBUG_CLIENT_FILE #ifdef DEBUG_CLIENT_FILE
WLog_DBG(TAG, "%s:i:%d", name, value); WLog_DBG(TAG, "%s:i:%d", name, value);
@ -196,7 +196,7 @@ static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name,
else if (_stricmp(name, "rdgiskdcproxy") == 0) else if (_stricmp(name, "rdgiskdcproxy") == 0)
file->RdgIsKdcProxy = value; file->RdgIsKdcProxy = value;
else else
bStandard = 1; standard = 1;
if (index >= 0) if (index >= 0)
{ {
@ -208,13 +208,13 @@ static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name,
file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED; file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED;
file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER; file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
if (bStandard) if (standard)
file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD; file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD;
file->lines[index].valueLength = 0; file->lines[index].valueLength = 0;
} }
return bStandard; return standard;
} }
static BOOL freerdp_client_parse_rdp_file_integer_unicode(rdpFile* file, WCHAR* name, WCHAR* value, int index) static BOOL freerdp_client_parse_rdp_file_integer_unicode(rdpFile* file, WCHAR* name, WCHAR* value, int index)
@ -270,7 +270,7 @@ static BOOL freerdp_client_parse_rdp_file_integer_ascii(rdpFile* file, const cha
static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value, int index) static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value, int index)
{ {
int bStandard = 0; int standard = 0;
LPSTR *tmp = NULL; LPSTR *tmp = NULL;
#ifdef DEBUG_CLIENT_FILE #ifdef DEBUG_CLIENT_FILE
@ -316,7 +316,7 @@ static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, c
else if (_stricmp(name, "winposstr") == 0) else if (_stricmp(name, "winposstr") == 0)
tmp = &file->WinPosStr; tmp = &file->WinPosStr;
else else
bStandard = 1; standard = 1;
if (tmp && !(*tmp = strdup(value))) if (tmp && !(*tmp = strdup(value)))
return -1; return -1;
@ -335,13 +335,13 @@ static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, c
file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED; file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED;
file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_STRING; file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_STRING;
if (bStandard == 0) if (standard == 0)
file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD; file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD;
file->lines[index].valueLength = 0; file->lines[index].valueLength = 0;
} }
return bStandard; return standard;
} }
static BOOL freerdp_client_add_option(rdpFile* file, char* option) static BOOL freerdp_client_add_option(rdpFile* file, char* option)

View File

@ -52,7 +52,7 @@ LPSTR freerdp_get_library_install_path()
CopyMemory(pszPath, pszInstallPrefix, cchInstallPrefix); CopyMemory(pszPath, pszInstallPrefix, cchInstallPrefix);
pszPath[cchInstallPrefix] = '\0'; pszPath[cchInstallPrefix] = '\0';
if (NativePathCchAppendA(pszPath, cchPath + 1, pszLibraryPath) != S_OK) if (FAILED(NativePathCchAppendA(pszPath, cchPath + 1, pszLibraryPath)))
{ {
free(pszPath); free(pszPath);
return NULL; return NULL;
@ -81,7 +81,7 @@ LPSTR freerdp_get_dynamic_addin_install_path()
CopyMemory(pszPath, pszInstallPrefix, cchInstallPrefix); CopyMemory(pszPath, pszInstallPrefix, cchInstallPrefix);
pszPath[cchInstallPrefix] = '\0'; pszPath[cchInstallPrefix] = '\0';
if (NativePathCchAppendA(pszPath, cchPath + 1, pszAddinPath) != S_OK) if (FAILED(NativePathCchAppendA(pszPath, cchPath + 1, pszAddinPath)))
{ {
free(pszPath); free(pszPath);
return NULL; return NULL;
@ -110,7 +110,7 @@ void* freerdp_load_dynamic_addin(LPCSTR pszFileName, LPCSTR pszPath, LPCSTR pszE
bHasExt = TRUE; bHasExt = TRUE;
cchFileName = strlen(pszFileName); cchFileName = strlen(pszFileName);
if (PathCchFindExtensionA(pszFileName, cchFileName + 1, &pszExt) != S_OK) if (FAILED(PathCchFindExtensionA(pszFileName, cchFileName + 1, &pszExt)))
{ {
pszExt = PathGetSharedLibraryExtensionA(PATH_SHARED_LIB_EXT_WITH_DOT); pszExt = PathGetSharedLibraryExtensionA(PATH_SHARED_LIB_EXT_WITH_DOT);
cchExt = strlen(pszExt); cchExt = strlen(pszExt);

View File

@ -2445,232 +2445,191 @@ char* freerdp_get_param_string(rdpSettings* settings, int id)
int freerdp_set_param_string(rdpSettings* settings, int id, const char* param) int freerdp_set_param_string(rdpSettings* settings, int id, const char* param)
{ {
#define CHECKED_STRDUP(name) if (param && !(settings->name = _strdup(param))) return -1 char **tmp = NULL;
if (!param)
return -1;
switch (id) switch (id)
{ {
case FreeRDP_ServerHostname: case FreeRDP_ServerHostname:
free(settings->ServerHostname); tmp = &settings->ServerHostname;
CHECKED_STRDUP(ServerHostname);
break; break;
case FreeRDP_Username: case FreeRDP_Username:
free(settings->Username); tmp = &settings->Username;
CHECKED_STRDUP(Username);
break; break;
case FreeRDP_Password: case FreeRDP_Password:
free(settings->Password); tmp = &settings->Password;
CHECKED_STRDUP(Password);
break; break;
case FreeRDP_Domain: case FreeRDP_Domain:
free(settings->Domain); tmp = &settings->Domain;
CHECKED_STRDUP(Domain);
break; break;
case FreeRDP_PasswordHash: case FreeRDP_PasswordHash:
free(settings->PasswordHash); tmp = &settings->PasswordHash;
CHECKED_STRDUP(PasswordHash);
break; break;
case FreeRDP_ClientHostname: case FreeRDP_ClientHostname:
free(settings->ClientHostname); tmp = &settings->ClientHostname;
CHECKED_STRDUP(ClientHostname);
break; break;
case FreeRDP_ClientProductId: case FreeRDP_ClientProductId:
free(settings->ClientProductId); tmp = &settings->ClientProductId;
CHECKED_STRDUP(ClientProductId);
break; break;
case FreeRDP_AlternateShell: case FreeRDP_AlternateShell:
free(settings->AlternateShell); tmp = &settings->AlternateShell;
CHECKED_STRDUP(AlternateShell);
break; break;
case FreeRDP_ShellWorkingDirectory: case FreeRDP_ShellWorkingDirectory:
free(settings->ShellWorkingDirectory); tmp = &settings->ShellWorkingDirectory;
CHECKED_STRDUP(ShellWorkingDirectory);
break; break;
case FreeRDP_ClientAddress: case FreeRDP_ClientAddress:
free(settings->ClientAddress); tmp = &settings->ClientAddress;
CHECKED_STRDUP(ClientAddress);
break; break;
case FreeRDP_ClientDir: case FreeRDP_ClientDir:
free(settings->ClientDir); tmp = &settings->ClientDir;
CHECKED_STRDUP(ClientDir);
break; break;
case FreeRDP_DynamicDSTTimeZoneKeyName: case FreeRDP_DynamicDSTTimeZoneKeyName:
free(settings->DynamicDSTTimeZoneKeyName); tmp = &settings->DynamicDSTTimeZoneKeyName;
CHECKED_STRDUP(DynamicDSTTimeZoneKeyName);
break; break;
case FreeRDP_RemoteAssistanceSessionId: case FreeRDP_RemoteAssistanceSessionId:
free(settings->RemoteAssistanceSessionId); tmp = &settings->RemoteAssistanceSessionId;
CHECKED_STRDUP(RemoteAssistanceSessionId);
break; break;
case FreeRDP_RemoteAssistancePassStub: case FreeRDP_RemoteAssistancePassStub:
free(settings->RemoteAssistancePassStub); tmp = &settings->RemoteAssistancePassStub;
CHECKED_STRDUP(RemoteAssistancePassStub);
break; break;
case FreeRDP_RemoteAssistancePassword: case FreeRDP_RemoteAssistancePassword:
free(settings->RemoteAssistancePassword); tmp = &settings->RemoteAssistancePassword;
CHECKED_STRDUP(RemoteAssistancePassword);
break; break;
case FreeRDP_RemoteAssistanceRCTicket: case FreeRDP_RemoteAssistanceRCTicket:
free(settings->RemoteAssistanceRCTicket); tmp = &settings->RemoteAssistanceRCTicket;
CHECKED_STRDUP(RemoteAssistanceRCTicket);
break; break;
case FreeRDP_AuthenticationServiceClass: case FreeRDP_AuthenticationServiceClass:
free(settings->AuthenticationServiceClass); tmp = &settings->AuthenticationServiceClass;
CHECKED_STRDUP(AuthenticationServiceClass);
break; break;
case FreeRDP_PreconnectionBlob: case FreeRDP_PreconnectionBlob:
free(settings->PreconnectionBlob); tmp = &settings->PreconnectionBlob;
CHECKED_STRDUP(PreconnectionBlob);
break; break;
case FreeRDP_KerberosKdc: case FreeRDP_KerberosKdc:
free(settings->KerberosKdc); tmp = &settings->KerberosKdc;
CHECKED_STRDUP(KerberosKdc);
break; break;
case FreeRDP_KerberosRealm: case FreeRDP_KerberosRealm:
free(settings->KerberosRealm); tmp = &settings->KerberosRealm;
CHECKED_STRDUP(KerberosRealm);
break; break;
case FreeRDP_CertificateName: case FreeRDP_CertificateName:
free(settings->CertificateName); tmp = &settings->CertificateName;
CHECKED_STRDUP(CertificateName);
break; break;
case FreeRDP_CertificateFile: case FreeRDP_CertificateFile:
free(settings->CertificateFile); tmp = &settings->CertificateFile;
CHECKED_STRDUP(CertificateFile);
break; break;
case FreeRDP_PrivateKeyFile: case FreeRDP_PrivateKeyFile:
free(settings->PrivateKeyFile); tmp = &settings->PrivateKeyFile;
CHECKED_STRDUP(PrivateKeyFile);
break; break;
case FreeRDP_RdpKeyFile: case FreeRDP_RdpKeyFile:
free(settings->RdpKeyFile); tmp = &settings->RdpKeyFile;
CHECKED_STRDUP(RdpKeyFile);
break; break;
case FreeRDP_WindowTitle: case FreeRDP_WindowTitle:
free(settings->WindowTitle); tmp = &settings->WindowTitle;
CHECKED_STRDUP(WindowTitle);
break; break;
case FreeRDP_ComputerName: case FreeRDP_ComputerName:
free(settings->ComputerName); tmp = &settings->ComputerName;
CHECKED_STRDUP(ComputerName);
break; break;
case FreeRDP_ConnectionFile: case FreeRDP_ConnectionFile:
free(settings->ConnectionFile); tmp = &settings->ConnectionFile;
CHECKED_STRDUP(ConnectionFile);
break; break;
case FreeRDP_AssistanceFile: case FreeRDP_AssistanceFile:
free(settings->AssistanceFile); tmp = &settings->AssistanceFile;
CHECKED_STRDUP(AssistanceFile);
break; break;
case FreeRDP_HomePath: case FreeRDP_HomePath:
free(settings->HomePath); tmp = &settings->HomePath;
CHECKED_STRDUP(HomePath);
break; break;
case FreeRDP_ConfigPath: case FreeRDP_ConfigPath:
free(settings->ConfigPath); tmp = &settings->ConfigPath;
CHECKED_STRDUP(ConfigPath);
break; break;
case FreeRDP_CurrentPath: case FreeRDP_CurrentPath:
free(settings->CurrentPath); tmp = &settings->CurrentPath;
CHECKED_STRDUP(CurrentPath);
break; break;
case FreeRDP_DumpRemoteFxFile: case FreeRDP_DumpRemoteFxFile:
free(settings->DumpRemoteFxFile); tmp = &settings->DumpRemoteFxFile;
CHECKED_STRDUP(DumpRemoteFxFile);
break; break;
case FreeRDP_PlayRemoteFxFile: case FreeRDP_PlayRemoteFxFile:
free(settings->PlayRemoteFxFile); tmp = &settings->PlayRemoteFxFile;
CHECKED_STRDUP(PlayRemoteFxFile);
break; break;
case FreeRDP_GatewayHostname: case FreeRDP_GatewayHostname:
free(settings->GatewayHostname); tmp = &settings->GatewayHostname;
CHECKED_STRDUP(GatewayHostname);
break; break;
case FreeRDP_GatewayUsername: case FreeRDP_GatewayUsername:
free(settings->GatewayUsername); tmp = &settings->GatewayUsername;
CHECKED_STRDUP(GatewayUsername);
break; break;
case FreeRDP_GatewayPassword: case FreeRDP_GatewayPassword:
free(settings->GatewayPassword); tmp = &settings->GatewayPassword;
CHECKED_STRDUP(GatewayPassword);
break; break;
case FreeRDP_GatewayDomain: case FreeRDP_GatewayDomain:
free(settings->GatewayDomain); tmp = &settings->GatewayDomain;
CHECKED_STRDUP(GatewayDomain);
break; break;
case FreeRDP_RemoteApplicationName: case FreeRDP_RemoteApplicationName:
free(settings->RemoteApplicationName); tmp = &settings->RemoteApplicationName;
CHECKED_STRDUP(RemoteApplicationName);
break; break;
case FreeRDP_RemoteApplicationIcon: case FreeRDP_RemoteApplicationIcon:
free(settings->RemoteApplicationIcon); tmp = &settings->RemoteApplicationIcon;
CHECKED_STRDUP(RemoteApplicationIcon);
break; break;
case FreeRDP_RemoteApplicationProgram: case FreeRDP_RemoteApplicationProgram:
free(settings->RemoteApplicationProgram); tmp = &settings->RemoteApplicationProgram;
CHECKED_STRDUP(RemoteApplicationProgram);
break; break;
case FreeRDP_RemoteApplicationFile: case FreeRDP_RemoteApplicationFile:
free(settings->RemoteApplicationFile); tmp = &settings->RemoteApplicationFile;
CHECKED_STRDUP(RemoteApplicationFile);
break; break;
case FreeRDP_RemoteApplicationGuid: case FreeRDP_RemoteApplicationGuid:
free(settings->RemoteApplicationGuid); tmp = &settings->RemoteApplicationGuid;
CHECKED_STRDUP(RemoteApplicationGuid);
break; break;
case FreeRDP_RemoteApplicationCmdLine: case FreeRDP_RemoteApplicationCmdLine:
free(settings->RemoteApplicationCmdLine); tmp = &settings->RemoteApplicationCmdLine;
CHECKED_STRDUP(RemoteApplicationCmdLine);
break; break;
case FreeRDP_ImeFileName: case FreeRDP_ImeFileName:
free(settings->ImeFileName); tmp = &settings->ImeFileName;
CHECKED_STRDUP(ImeFileName);
break; break;
case FreeRDP_DrivesToRedirect: case FreeRDP_DrivesToRedirect:
free(settings->DrivesToRedirect); tmp = &settings->DrivesToRedirect;
CHECKED_STRDUP(DrivesToRedirect);
break; break;
default: default:
@ -2678,6 +2637,10 @@ int freerdp_set_param_string(rdpSettings* settings, int id, const char* param)
return -1; return -1;
} }
free(*tmp);
if (!(*tmp = _strdup(param)))
return -1;
/* Mark field as modified */ /* Mark field as modified */
settings->SettingsModified[id] = 1; settings->SettingsModified[id] = 1;

View File

@ -836,11 +836,11 @@ rdpCertificate* certificate_clone(rdpCertificate* certificate)
return _certificate; return _certificate;
out_fail: out_fail:
if (certificate->x509_cert_chain->count) if (_certificate->x509_cert_chain)
{ {
free(_certificate->x509_cert_chain->array); free(_certificate->x509_cert_chain->array);
free(_certificate->x509_cert_chain);
} }
free(_certificate->x509_cert_chain);
free(_certificate->cert_info.Modulus); free(_certificate->cert_info.Modulus);
free(_certificate); free(_certificate);
return NULL; return NULL;

View File

@ -983,15 +983,12 @@ static BOOL nla_read_ts_credentials(rdpNla* nla, PSecBuffer ts_credentials)
/* TSCredentials (SEQUENCE) */ /* TSCredentials (SEQUENCE) */
ret = ber_read_sequence_tag(s, &length) && ret = ber_read_sequence_tag(s, &length) &&
/* [0] credType (INTEGER) */ /* [0] credType (INTEGER) */
ber_read_contextual_tag(s, 0, &length, TRUE) && ber_read_contextual_tag(s, 0, &length, TRUE) &&
ber_read_integer(s, NULL) && ber_read_integer(s, NULL) &&
/* [1] credentials (OCTET STRING) */ /* [1] credentials (OCTET STRING) */
ber_read_contextual_tag(s, 1, &length, TRUE) && ber_read_contextual_tag(s, 1, &length, TRUE) &&
ber_read_octet_string_tag(s, &ts_password_creds_length) && ber_read_octet_string_tag(s, &ts_password_creds_length) &&
nla_read_ts_password_creds(nla, s); nla_read_ts_password_creds(nla, s);
Stream_Free(s, FALSE); Stream_Free(s, FALSE);
@ -1467,10 +1464,6 @@ LPTSTR nla_make_spn(const char* ServiceClass, const char* hostname)
rdpNla* nla_new(freerdp* instance, rdpTransport* transport, rdpSettings* settings) rdpNla* nla_new(freerdp* instance, rdpTransport* transport, rdpSettings* settings)
{ {
HKEY hKey;
LONG status;
DWORD dwType;
DWORD dwSize;
rdpNla* nla = (rdpNla*) calloc(1, sizeof(rdpNla)); rdpNla* nla = (rdpNla*) calloc(1, sizeof(rdpNla));
@ -1498,6 +1491,11 @@ rdpNla* nla_new(freerdp* instance, rdpTransport* transport, rdpSettings* setting
if (nla->server) if (nla->server)
{ {
LONG status;
HKEY hKey;
DWORD dwType;
DWORD dwSize;
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"), status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software\\FreeRDP\\Server"),
0, KEY_READ | KEY_WOW64_64KEY, &hKey); 0, KEY_READ | KEY_WOW64_64KEY, &hKey);
@ -1506,11 +1504,15 @@ rdpNla* nla_new(freerdp* instance, rdpTransport* transport, rdpSettings* setting
status = RegQueryValueEx(hKey, _T("SspiModule"), NULL, &dwType, NULL, &dwSize); status = RegQueryValueEx(hKey, _T("SspiModule"), NULL, &dwType, NULL, &dwSize);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return nla; return nla;
}
nla->SspiModule = (LPTSTR) malloc(dwSize + sizeof(TCHAR)); nla->SspiModule = (LPTSTR) malloc(dwSize + sizeof(TCHAR));
if (!nla->SspiModule) if (!nla->SspiModule)
{ {
RegCloseKey(hKey);
free(nla); free(nla);
return NULL; return NULL;
} }
@ -1519,10 +1521,9 @@ rdpNla* nla_new(freerdp* instance, rdpTransport* transport, rdpSettings* setting
(BYTE*) nla->SspiModule, &dwSize); (BYTE*) nla->SspiModule, &dwSize);
if (status == ERROR_SUCCESS) if (status == ERROR_SUCCESS)
{
WLog_INFO(TAG, "Using SSPI Module: %s", nla->SspiModule); WLog_INFO(TAG, "Using SSPI Module: %s", nla->SspiModule);
RegCloseKey(hKey);
} RegCloseKey(hKey);
} }
return nla; return nla;

View File

@ -196,7 +196,7 @@ void settings_load_hkey_local_machine(rdpSettings* settings)
BOOL settings_get_computer_name(rdpSettings* settings) BOOL settings_get_computer_name(rdpSettings* settings)
{ {
DWORD nSize = MAX_COMPUTERNAME_LENGTH + 1; DWORD nSize = MAX_COMPUTERNAME_LENGTH + 1;
TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; CHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
if (!GetComputerNameExA(ComputerNameNetBIOS, computerName, &nSize)) if (!GetComputerNameExA(ComputerNameNetBIOS, computerName, &nSize))
return FALSE; return FALSE;

View File

@ -64,7 +64,7 @@ BOOL pcap_write_header(rdpPcap* pcap, pcap_header* header)
BOOL pcap_read_record_header(rdpPcap* pcap, pcap_record_header* record) BOOL pcap_read_record_header(rdpPcap* pcap, pcap_record_header* record)
{ {
return fread((void*) record, sizeof(pcap_record_header), 1, pcap->fp) > 0; return fread((void*) record, sizeof(pcap_record_header), 1, pcap->fp) == 1;
} }
void pcap_write_record_header(rdpPcap* pcap, pcap_record_header* record) void pcap_write_record_header(rdpPcap* pcap, pcap_record_header* record)
@ -82,7 +82,7 @@ BOOL pcap_read_record(rdpPcap* pcap, pcap_record* record)
if (!record->data) if (!record->data)
return FALSE; return FALSE;
if (!fread(record->data, record->length, 1, pcap->fp)) if (fread(record->data, record->length, 1, pcap->fp) != 1)
{ {
free(record->data); free(record->data);
record->data = NULL; record->data = NULL;

View File

@ -258,7 +258,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
settings->NSCodec = FALSE; settings->NSCodec = FALSE;
settings->JpegCodec = FALSE; settings->JpegCodec = FALSE;
if (!wf_peer_read_settings(client)) if (!wf_peer_read_settings(client))
goto fail_peer_init; goto fail_peer_init;
client->PostConnect = wf_peer_post_connect; client->PostConnect = wf_peer_post_connect;
client->Activate = wf_peer_activate; client->Activate = wf_peer_activate;

View File

@ -152,8 +152,8 @@ static char* GetPath_XDG_CONFIG_HOME(void)
if (!path) if (!path)
return NULL; return NULL;
if (SHGetFolderPathA(0, CSIDL_APPDATA, NULL, if (FAILED(SHGetFolderPathA(0, CSIDL_APPDATA, NULL,
SHGFP_TYPE_CURRENT, path) != S_OK) SHGFP_TYPE_CURRENT, path)))
{ {
free(path); free(path);
return NULL; return NULL;
@ -250,8 +250,8 @@ char* GetPath_XDG_RUNTIME_DIR(void)
if (!path) if (!path)
return NULL; return NULL;
if (SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA, NULL, if (FAILED(SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA, NULL,
SHGFP_TYPE_CURRENT, path) != S_OK) SHGFP_TYPE_CURRENT, path)))
{ {
free(path); free(path);
return NULL; return NULL;
@ -407,7 +407,7 @@ char* GetCombinedPath(const char* basePath, const char* subPath)
CopyMemory(path, basePath, basePathLength); CopyMemory(path, basePath, basePathLength);
path[basePathLength] = '\0'; path[basePathLength] = '\0';
if (PathCchConvertStyleA(path, basePathLength, PATH_STYLE_NATIVE) != S_OK) if (FAILED(PathCchConvertStyleA(path, basePathLength, PATH_STYLE_NATIVE)))
{ {
free(path); free(path);
return NULL; return NULL;
@ -422,7 +422,7 @@ char* GetCombinedPath(const char* basePath, const char* subPath)
free(path); free(path);
return NULL; return NULL;
} }
if (PathCchConvertStyleA(subPathCpy, subPathLength, PATH_STYLE_NATIVE) != S_OK) if (FAILED(PathCchConvertStyleA(subPathCpy, subPathLength, PATH_STYLE_NATIVE)))
{ {
free(path); free(path);
free(subPathCpy); free(subPathCpy);
@ -433,7 +433,7 @@ char* GetCombinedPath(const char* basePath, const char* subPath)
free(subPathCpy); free(subPathCpy);
if (status != S_OK) if (FAILED(status))
{ {
free(path); free(path);
return NULL; return NULL;

View File

@ -50,7 +50,7 @@ int ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation)
int status; int status;
DWORD nSize = MAX_COMPUTERNAME_LENGTH; DWORD nSize = MAX_COMPUTERNAME_LENGTH;
char* ws = Workstation; char* ws = Workstation;
TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; CHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
if (!Workstation) if (!Workstation)
{ {
@ -110,7 +110,7 @@ int ntlm_SetContextServicePrincipalNameA(NTLM_CONTEXT* context, char* ServicePri
int ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName) int ntlm_SetContextTargetName(NTLM_CONTEXT* context, char* TargetName)
{ {
int status; int status;
TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; CHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD nSize = MAX_COMPUTERNAME_LENGTH; DWORD nSize = MAX_COMPUTERNAME_LENGTH;
char* name = TargetName; char* name = TargetName;

View File

@ -172,7 +172,7 @@ int ntlm_get_target_computer_name(PUNICODE_STRING pName, COMPUTER_NAME_FORMAT ty
{ {
char* name; char* name;
int status; int status;
TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; CHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD nSize = MAX_COMPUTERNAME_LENGTH; DWORD nSize = MAX_COMPUTERNAME_LENGTH;
if (!GetComputerNameExA(type, computerName, &nSize)) if (!GetComputerNameExA(type, computerName, &nSize))

View File

@ -32,9 +32,9 @@ int TestAcquireCredentialsHandle(int argc, char* argv[])
fprintf(stderr, "Memory allocation failed\n"); fprintf(stderr, "Memory allocation failed\n");
return -1; return -1;
} }
identity.UserLength = sizeof(test_User); identity.UserLength = strlen(test_User);
identity.DomainLength = sizeof(test_Domain); identity.DomainLength = strlen(test_Domain);
identity.PasswordLength = sizeof(test_Password); identity.PasswordLength = strlen(test_Password);
identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME, status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME,

View File

@ -51,9 +51,9 @@ int TestInitializeSecurityContext(int argc, char* argv[])
return -1; return -1;
} }
identity.UserLength = sizeof(test_User); identity.UserLength = strlen(test_User);
identity.DomainLength = sizeof(test_Domain); identity.DomainLength = strlen(test_Domain);
identity.PasswordLength = sizeof(test_Password); identity.PasswordLength = strlen(test_Password);
identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME, status = table->AcquireCredentialsHandle(NULL, NTLMSP_NAME,

View File

@ -297,7 +297,7 @@ int schannel_recv(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle phCont
ZeroMemory(&StreamSizes, sizeof(SecPkgContext_StreamSizes)); ZeroMemory(&StreamSizes, sizeof(SecPkgContext_StreamSizes));
status = table->QueryContextAttributes(phContext, SECPKG_ATTR_STREAM_SIZES, &StreamSizes); status = table->QueryContextAttributes(phContext, SECPKG_ATTR_STREAM_SIZES, &StreamSizes);
ioBufferLength = StreamSizes.cbHeader + StreamSizes.cbMaximumMessage + StreamSizes.cbTrailer; ioBufferLength = StreamSizes.cbHeader + StreamSizes.cbMaximumMessage + StreamSizes.cbTrailer;
ioBuffer = (BYTE*) malloc(1, ioBufferLength); ioBuffer = (BYTE*) calloc(1, ioBufferLength);
if (!ioBuffer) if (!ioBuffer)
return -1; return -1;

View File

@ -89,7 +89,13 @@ BOOL Pcap_Read_Record(wPcap* pcap, wPcapRecord* record)
record->data = malloc(record->length); record->data = malloc(record->length);
if (!record->data) if (!record->data)
return FALSE; return FALSE;
fread(record->data, record->length, 1, pcap->fp); if (fread(record->data, record->length, 1, pcap->fp) != 1)
{
free(record->data);
record->length = 0;
record->data = NULL;
return FALSE;
}
} }
return TRUE; return TRUE;
} }

View File

@ -306,7 +306,7 @@ char* x509_name_parse(char* name, char* txt, int* length)
char* x509_get_default_name() char* x509_get_default_name()
{ {
TCHAR computerName[MAX_COMPUTERNAME_LENGTH + 1]; CHAR computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD nSize = MAX_COMPUTERNAME_LENGTH; DWORD nSize = MAX_COMPUTERNAME_LENGTH;
char* ret; char* ret;