Fixed memory leaks.
This commit is contained in:
parent
704d69d540
commit
eacf2b542e
@ -250,7 +250,7 @@ int freerdp_assistance_parse_connection_string1(rdpAssistanceFile* file)
|
||||
int count;
|
||||
int length;
|
||||
char* tokens[8];
|
||||
int ret;
|
||||
int ret = -1;
|
||||
|
||||
/**
|
||||
* <ProtocolVersion>,<protocolType>,<machineAddressList>,<assistantAccountPwd>,
|
||||
@ -272,7 +272,7 @@ int freerdp_assistance_parse_connection_string1(rdpAssistanceFile* file)
|
||||
}
|
||||
|
||||
if (count != 8)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
count = 0;
|
||||
tokens[count++] = str;
|
||||
@ -287,32 +287,33 @@ int freerdp_assistance_parse_connection_string1(rdpAssistanceFile* file)
|
||||
}
|
||||
|
||||
if (strcmp(tokens[0], "65538") != 0)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
if (strcmp(tokens[1], "1") != 0)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
if (strcmp(tokens[3], "*") != 0)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
if (strcmp(tokens[5], "*") != 0)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
if (strcmp(tokens[6], "*") != 0)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
file->RASessionId = _strdup(tokens[4]);
|
||||
|
||||
if (!file->RASessionId)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
file->RASpecificParams = _strdup(tokens[7]);
|
||||
|
||||
if (!file->RASpecificParams)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
ret = freerdp_assistance_parse_address_list(file, tokens[2]);
|
||||
|
||||
error:
|
||||
free(str);
|
||||
|
||||
if (ret != 1)
|
||||
|
@ -504,7 +504,11 @@ BOOL http_response_parse_header_field(HttpResponse* response, char* name, char*
|
||||
authValue = _strdup(separator + 1);
|
||||
|
||||
if (!authScheme || !authValue)
|
||||
{
|
||||
free(authScheme);
|
||||
free(authValue);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*separator = ' ';
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char*
|
||||
|
||||
BOOL ntlm_client_make_spn(rdpNtlm* ntlm, LPCTSTR ServiceClass, char* hostname)
|
||||
{
|
||||
BOOL status = FALSE;
|
||||
DWORD SpnLength = 0;
|
||||
LPTSTR hostnameX = NULL;
|
||||
|
||||
@ -128,19 +129,22 @@ BOOL ntlm_client_make_spn(rdpNtlm* ntlm, LPCTSTR ServiceClass, char* hostname)
|
||||
}
|
||||
|
||||
if (DsMakeSpn(ServiceClass, hostnameX, NULL, 0, NULL, &SpnLength, NULL) != ERROR_BUFFER_OVERFLOW)
|
||||
return FALSE;
|
||||
goto error;
|
||||
|
||||
ntlm->ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
|
||||
|
||||
if (!ntlm->ServicePrincipalName)
|
||||
return FALSE;
|
||||
goto error;
|
||||
|
||||
if (DsMakeSpn(ServiceClass, hostnameX, NULL, 0, NULL, &SpnLength, ntlm->ServicePrincipalName) != ERROR_SUCCESS)
|
||||
return FALSE;
|
||||
goto error;
|
||||
|
||||
status = TRUE;
|
||||
|
||||
error:
|
||||
free(hostnameX);
|
||||
|
||||
return TRUE;
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1673,7 +1673,11 @@ LPTSTR nla_make_spn(const char* ServiceClass, const char* hostname)
|
||||
ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
|
||||
|
||||
if (!ServicePrincipalName)
|
||||
{
|
||||
free(ServiceClassX);
|
||||
free(hostnameX);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = DsMakeSpn(ServiceClassX, hostnameX, NULL, 0, NULL, &SpnLength, ServicePrincipalName);
|
||||
|
||||
|
@ -165,7 +165,10 @@ int x11_shadow_pam_authenticate(x11ShadowSubsystem* subsystem, rdpShadowClient*
|
||||
return PAM_CONV_ERR;
|
||||
|
||||
if (x11_shadow_pam_get_service_name(info) < 0)
|
||||
{
|
||||
free(info);
|
||||
return -1;
|
||||
}
|
||||
|
||||
info->appdata.user = user;
|
||||
info->appdata.domain = domain;
|
||||
|
@ -204,7 +204,10 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
|
||||
p = strchr(p + 1, ',');
|
||||
|
||||
if (!p)
|
||||
{
|
||||
free(str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*p++ = '\0';
|
||||
tok[1] = p;
|
||||
@ -212,7 +215,10 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
|
||||
p = strchr(p + 1, ',');
|
||||
|
||||
if (!p)
|
||||
{
|
||||
free(str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*p++ = '\0';
|
||||
tok[2] = p;
|
||||
@ -220,7 +226,10 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
|
||||
p = strchr(p + 1, ',');
|
||||
|
||||
if (!p)
|
||||
{
|
||||
free(str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*p++ = '\0';
|
||||
tok[3] = p;
|
||||
@ -229,6 +238,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a
|
||||
y = atoi(tok[1]);
|
||||
w = atoi(tok[2]);
|
||||
h = atoi(tok[3]);
|
||||
free(str);
|
||||
|
||||
if ((x < 0) || (y < 0) || (w < 1) || (h < 1))
|
||||
return -1;
|
||||
|
@ -2427,7 +2427,10 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWOR
|
||||
friendlyNameA = _strdup(nameWinSCard);
|
||||
|
||||
if (!friendlyNameA)
|
||||
{
|
||||
free(namePCSC);
|
||||
return SCARD_E_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2442,7 +2445,10 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWOR
|
||||
free(friendlyNameA);
|
||||
|
||||
if (!friendlyNameW)
|
||||
{
|
||||
free(namePCSC);
|
||||
return SCARD_E_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (cbAttrLen == SCARD_AUTOALLOCATE)
|
||||
{
|
||||
@ -2455,6 +2461,7 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWOR
|
||||
if ((length * 2) > cbAttrLen)
|
||||
{
|
||||
free(friendlyNameW);
|
||||
free(namePCSC);
|
||||
return SCARD_E_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
else
|
||||
@ -2478,6 +2485,7 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWOR
|
||||
if ((length + 1) > cbAttrLen)
|
||||
{
|
||||
free(friendlyNameA);
|
||||
free(namePCSC);
|
||||
return SCARD_E_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
else
|
||||
|
@ -1932,15 +1932,14 @@ DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
|
||||
* 2 ... TIME_ZONE_ID_DAYLIGHT */
|
||||
return local_time->tm_isdst ? 2 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* could not detect timezone, use computed bias from tm_gmtoff */
|
||||
WLog_DBG(TAG, "tz not found, using computed bias %d.", tz->Bias);
|
||||
|
||||
/* could not detect timezone, use computed bias from tm_gmtoff */
|
||||
WLog_DBG(TAG, "tz not found, using computed bias %d.", tz->Bias);
|
||||
out_error:
|
||||
memcpy(tz->StandardName, L"Client Local Time", sizeof(tz->StandardName));
|
||||
memcpy(tz->DaylightName, L"Client Local Time", sizeof(tz->DaylightName));
|
||||
return 0; /* TIME_ZONE_ID_UNKNOWN */
|
||||
}
|
||||
free(dtz);
|
||||
memcpy(tz->StandardName, L"Client Local Time", sizeof(tz->StandardName));
|
||||
memcpy(tz->DaylightName, L"Client Local Time", sizeof(tz->DaylightName));
|
||||
return 0; /* TIME_ZONE_ID_UNKNOWN */
|
||||
}
|
||||
|
||||
BOOL SetTimeZoneInformation(const TIME_ZONE_INFORMATION* lpTimeZoneInformation)
|
||||
|
@ -34,20 +34,24 @@
|
||||
|
||||
BYTE* NTOWFv1W(LPWSTR Password, UINT32 PasswordLength, BYTE* NtHash)
|
||||
{
|
||||
BOOL allocate = !NtHash;
|
||||
WINPR_MD4_CTX md4;
|
||||
|
||||
if (!Password)
|
||||
return NULL;
|
||||
|
||||
if (!NtHash && !(NtHash = malloc(16)))
|
||||
return NULL;
|
||||
|
||||
if (!winpr_MD4_Init(&md4))
|
||||
return NULL;
|
||||
if (!winpr_MD4_Update(&md4, (BYTE*) Password, (size_t) PasswordLength))
|
||||
return NULL;
|
||||
if (!winpr_MD4_Final(&md4, NtHash, WINPR_MD4_DIGEST_LENGTH))
|
||||
if (!NtHash && !(NtHash = malloc(WINPR_MD4_DIGEST_LENGTH)))
|
||||
return NULL;
|
||||
if (!winpr_MD4_Final(&md4, NtHash, WINPR_MD4_DIGEST_LENGTH))
|
||||
{
|
||||
if (allocate)
|
||||
free(NtHash);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NtHash;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user