[winpr] fix cast warnings

This commit is contained in:
Armin Novak 2023-07-28 09:42:01 +02:00 committed by akallabeth
parent 61625f1a2a
commit 4f7a3762ae
6 changed files with 17 additions and 13 deletions

View File

@ -169,8 +169,8 @@ static int ntlm_SetContextServicePrincipalNameW(NTLM_CONTEXT* context, LPWSTR Se
if (!context->ServicePrincipalName.Buffer)
return -1;
CopyMemory(context->ServicePrincipalName.Buffer, ServicePrincipalName,
context->ServicePrincipalName.Length + 2);
memcpy(context->ServicePrincipalName.Buffer, ServicePrincipalName,
context->ServicePrincipalName.Length + 2);
return 1;
}

View File

@ -56,7 +56,7 @@ BOOL NTOWFv1A(LPSTR Password, UINT32 PasswordLength, BYTE* NtHash)
if (!PasswordW)
return FALSE;
if (!NTOWFv1W(PasswordW, pwdCharLength * sizeof(WCHAR), NtHash))
if (!NTOWFv1W(PasswordW, (UINT32)pwdCharLength * sizeof(WCHAR), NtHash))
goto out_fail;
result = TRUE;
@ -107,8 +107,9 @@ BOOL NTOWFv2A(LPSTR Password, UINT32 PasswordLength, LPSTR User, UINT32 UserLeng
if (!UserW || !DomainW || !PasswordW)
goto out_fail;
if (!NTOWFv2W(PasswordW, pwdCharLength * sizeof(WCHAR), UserW, userCharLength * sizeof(WCHAR),
DomainW, domainCharLength * sizeof(WCHAR), NtHash))
if (!NTOWFv2W(PasswordW, (UINT32)pwdCharLength * sizeof(WCHAR), UserW,
(UINT32)userCharLength * sizeof(WCHAR), DomainW,
(UINT32)domainCharLength * sizeof(WCHAR), NtHash))
goto out_fail;
result = TRUE;
@ -169,8 +170,8 @@ BOOL NTOWFv2FromHashA(BYTE* NtHashV1, LPSTR User, UINT32 UserLength, LPSTR Domai
if (!UserW || !DomainW)
goto out_fail;
if (!NTOWFv2FromHashW(NtHashV1, UserW, userCharLength * sizeof(WCHAR), DomainW,
domainCharLength * sizeof(WCHAR), NtHash))
if (!NTOWFv2FromHashW(NtHashV1, UserW, (UINT32)userCharLength * sizeof(WCHAR), DomainW,
(UINT32)domainCharLength * sizeof(WCHAR), NtHash))
goto out_fail;
result = TRUE;

View File

@ -348,7 +348,7 @@ WINPR_SAM_ENTRY* SamLookupUserW(WINPR_SAM* sam, LPCWSTR User, UINT32 UserLength,
if (!utfDomain)
goto fail;
}
entry = SamLookupUserA(sam, utfUser, userCharLen, utfDomain, domainCharLen);
entry = SamLookupUserA(sam, utfUser, (UINT32)userCharLen, utfDomain, (UINT32)domainCharLen);
fail:
free(utfUser);
free(utfDomain);

View File

@ -141,8 +141,8 @@ char* winpr_win_strerror(DWORD dw, char* dmsg, size_t size)
alloc = TRUE;
dwFlags |= FORMAT_MESSAGE_ALLOCATE_BUFFER;
#else
nSize = (DWORD)(size * 2);
msg = (LPTSTR)calloc(nSize, sizeof(TCHAR));
nSize = (DWORD)(size * sizeof(WCHAR));
msg = (LPTSTR)calloc(nSize, sizeof(WCHAR));
#endif
rc = FormatMessage(dwFlags, NULL, dw, 0, alloc ? (LPTSTR)&msg : msg, nSize, NULL);

View File

@ -469,8 +469,10 @@ BOOL WLog_PacketMessage_Write(wPcap* pcap, void* data, size_t length, DWORD flag
tcp.UrgentPointer = 0;
record.data = data;
record.length = length;
record.header.incl_len = record.length + 14 + 20 + 20;
record.header.orig_len = record.length + 14 + 20 + 20;
const size_t offset = 14 + 20 + 20;
WINPR_ASSERT(record.length <= UINT32_MAX - offset);
record.header.incl_len = (UINT32)record.length + offset;
record.header.orig_len = (UINT32)record.length + offset;
record.next = NULL;
gettimeofday(&tp, 0);
record.header.ts_sec = tp.tv_sec;

View File

@ -735,7 +735,8 @@ static BOOL makecert_create_rsa(EVP_PKEY** ppkey, size_t key_length)
if (EVP_PKEY_keygen_init(pctx) != 1)
goto fail;
unsigned int keylen = key_length;
WINPR_ASSERT(key_length <= UINT_MAX);
unsigned int keylen = (unsigned int)key_length;
const OSSL_PARAM params[] = { OSSL_PARAM_construct_uint("bits", &keylen),
OSSL_PARAM_construct_end() };
if (EVP_PKEY_CTX_set_params(pctx, params) != 1)