Fixed integer warnings

This commit is contained in:
akallabeth 2021-06-17 11:25:58 +02:00 committed by akallabeth
parent 8b01c2f8ae
commit 6726772d8d
19 changed files with 130 additions and 101 deletions

View File

@ -143,7 +143,7 @@ BOOL ntlm_client_make_spn(rdpNtlm* ntlm, LPCSTR ServiceClass, LPCSTR hostname)
LPWSTR hostnameX = NULL;
ConvertToUnicode(CP_UTF8, 0, hostname, -1, (LPWSTR*)&hostnameX, 0);
#else
LPCSTR hostnameX = _strdup(hostname);
LPSTR hostnameX = _strdup(hostname);
#endif
if (!hostnameX)
@ -151,12 +151,7 @@ BOOL ntlm_client_make_spn(rdpNtlm* ntlm, LPCSTR ServiceClass, LPCSTR hostname)
if (!ServiceClass)
{
ntlm->ServicePrincipalName = (LPTSTR)_tcsdup(hostnameX);
free(hostnameX);
if (!ntlm->ServicePrincipalName)
return FALSE;
ntlm->ServicePrincipalName = hostnameX;
return TRUE;
}

View File

@ -1128,12 +1128,7 @@ static BOOL rdg_set_ntlm_auth_header(rdpNtlm* ntlm, HttpRequest* request)
char* base64NtlmToken = NULL;
if (ntlmToken)
{
if (ntlmToken->cbBuffer > INT_MAX)
return FALSE;
base64NtlmToken = crypto_base64_encode(ntlmToken->pvBuffer, (int)ntlmToken->cbBuffer);
}
base64NtlmToken = crypto_base64_encode(ntlmToken->pvBuffer, ntlmToken->cbBuffer);
if (base64NtlmToken)
{

View File

@ -737,7 +737,7 @@ struct rdp_rpc
UINT32 result;
rdpNtlm* ntlm;
int SendSeqNum;
size_t SendSeqNum;
RpcClient* client;

View File

@ -1190,7 +1190,7 @@ static int nla_server_authenticate(rdpNla* nla)
{
SECURITY_STATUS status;
status = nla->table->SetContextAttributes(
&nla->context, SECPKG_ATTR_AUTH_NTLM_HASH_CB, peer->ComputeNtlmHash, 0);
&nla->context, SECPKG_ATTR_AUTH_NTLM_HASH_CB, (void*)peer->ComputeNtlmHash, 0);
if (status != SEC_E_OK)
{

View File

@ -82,7 +82,7 @@ DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer)
memcpy(lpBuffer, cwd, length + 1);
free(cwd);
return length;
return (DWORD)length;
}
}
@ -154,12 +154,12 @@ DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize)
length = strlen(env);
if ((length + 1 > nSize) || (!lpBuffer))
return length + 1;
return (DWORD)length + 1;
CopyMemory(lpBuffer, env, length);
lpBuffer[length] = '\0';
return length;
return (DWORD)length;
#else
SetLastError(ERROR_ENVVAR_NOT_FOUND);
return 0;

View File

@ -164,7 +164,7 @@ static DWORD FileSetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDist
return INVALID_SET_FILE_POINTER;
}
return _ftelli64(pFile->fp);
return (DWORD)_ftelli64(pFile->fp);
}
static BOOL FileSetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove,

View File

@ -289,7 +289,7 @@ DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
{
CopyMemory(lpFilename, buffer, length);
lpFilename[length] = '\0';
return length;
return (DWORD)length;
}
CopyMemory(lpFilename, buffer, nSize - 1);

View File

@ -25,7 +25,8 @@ set(${MODULE_PREFIX}_NTLM_SRCS
NTLM/ntlm_message.c
NTLM/ntlm_message.h
NTLM/ntlm.c
NTLM/ntlm.h)
NTLM/ntlm.h
NTLM/ntlm_export.h)
set(${MODULE_PREFIX}_KERBEROS_SRCS
Kerberos/kerberos.c

View File

@ -22,6 +22,7 @@
#endif
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <winpr/sspi.h>
#include <winpr/print.h>
#include <winpr/tchar.h>
@ -31,6 +32,7 @@
#include <freerdp/build-config.h>
#include "ntlm.h"
#include "ntlm_export.h"
#include "../sspi.h"
#include "ntlm_message.h"
@ -40,7 +42,7 @@
#define WINPR_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\WinPR\\NTLM"
static const char* NTLM_PACKAGE_NAME = "NTLM";
static char* NTLM_PACKAGE_NAME = "NTLM";
static int ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation)
{
@ -749,8 +751,10 @@ static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phCont
if (credentials->identity.UserLength > 0)
{
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)credentials->identity.User,
credentials->identity.UserLength, &UserA, 256, NULL, NULL);
WINPR_ASSERT(credentials->identity.UserLength <= INT_MAX);
status =
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)credentials->identity.User,
(int)credentials->identity.UserLength, &UserA, 256, NULL, NULL);
if (status <= 0)
return SEC_E_INTERNAL_ERROR;
@ -760,9 +764,10 @@ static SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phCont
if (credentials->identity.DomainLength > 0)
{
status =
ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)credentials->identity.Domain,
credentials->identity.DomainLength, &DomainA, 256, NULL, NULL);
WINPR_ASSERT(credentials->identity.DomainLength <= INT_MAX);
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*)credentials->identity.Domain,
(int)credentials->identity.DomainLength, &DomainA, 256,
NULL, NULL);
if (status <= 0)
return SEC_E_INTERNAL_ERROR;
@ -965,7 +970,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, ULON
PSecBufferDesc pMessage, ULONG MessageSeqNo)
{
ULONG index;
int length;
size_t length;
void* data;
UINT32 SeqNo;
UINT32 value;
@ -1061,8 +1066,8 @@ static SECURITY_STATUS SEC_ENTRY ntlm_EncryptMessage(PCtxtHandle phContext, ULON
static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage,
ULONG MessageSeqNo, PULONG pfQOP)
{
int index;
int length;
ULONG index;
size_t length;
void* data;
UINT32 SeqNo;
UINT32 value;
@ -1077,7 +1082,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_DecryptMessage(PCtxtHandle phContext, PSec
SeqNo = (UINT32)MessageSeqNo;
context = (NTLM_CONTEXT*)sspi_SecureHandleGetLowerPointer(phContext);
for (index = 0; index < (int)pMessage->cBuffers; index++)
for (index = 0; index < pMessage->cBuffers; index++)
{
if (pMessage->pBuffers[index].BufferType == SECBUFFER_DATA)
data_buffer = &pMessage->pBuffers[index];

View File

@ -124,6 +124,7 @@ static INLINE BOOL ntlm_av_pair_get_id(const NTLM_AV_PAIR* pAvPair, size_t size,
ULONG ntlm_av_pair_list_length(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList)
{
size_t size;
size_t cbAvPair;
NTLM_AV_PAIR* pAvPair;
@ -131,7 +132,9 @@ ULONG ntlm_av_pair_list_length(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList)
if (!pAvPair)
return 0;
return ((PBYTE)pAvPair - (PBYTE)pAvPairList) + sizeof(NTLM_AV_PAIR);
size = ((PBYTE)pAvPair - (PBYTE)pAvPairList) + sizeof(NTLM_AV_PAIR);
WINPR_ASSERT(size <= ULONG_MAX);
return (ULONG)size;
}
static INLINE BOOL ntlm_av_pair_get_len(const NTLM_AV_PAIR* pAvPair, size_t size, size_t* pAvLen)
@ -259,7 +262,7 @@ static BOOL ntlm_av_pair_add(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList, NTL
if (!pAvPair || cbAvPair < 2 * sizeof(NTLM_AV_PAIR) + AvLen)
return FALSE;
ntlm_av_pair_set_id(pAvPair, AvId);
ntlm_av_pair_set_id(pAvPair, (UINT16)AvId);
ntlm_av_pair_set_len(pAvPair, AvLen);
if (AvLen)
{
@ -286,8 +289,9 @@ static BOOL ntlm_av_pair_add_copy(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList
if (!ntlm_av_pair_get_len(pAvPair, cbAvPair, &avLen))
return FALSE;
WINPR_ASSERT(avLen <= UINT16_MAX);
return ntlm_av_pair_add(pAvPairList, cbAvPairList, pair,
ntlm_av_pair_get_value_pointer(pAvPair), avLen);
ntlm_av_pair_get_value_pointer(pAvPair), (UINT16)avLen);
}
static int ntlm_get_target_computer_name(PUNICODE_STRING pName, COMPUTER_NAME_FORMAT type)
@ -454,7 +458,7 @@ static void ntlm_compute_single_host_data(NTLM_CONTEXT* context)
int ntlm_construct_challenge_target_info(NTLM_CONTEXT* context)
{
int rc = -1;
int length;
ULONG length;
ULONG AvPairsCount;
ULONG AvPairsLength;
NTLM_AV_PAIR* pAvPairList;
@ -714,8 +718,10 @@ int ntlm_construct_authenticate_target_info(NTLM_CONTEXT* context)
if (context->SendSingleHostData)
{
WINPR_ASSERT(context->SingleHostData.Size <= UINT16_MAX);
if (!ntlm_av_pair_add(AuthenticateTargetInfo, cbAuthenticateTargetInfo, MsvAvSingleHost,
(PBYTE)&context->SingleHostData, context->SingleHostData.Size))
(PBYTE)&context->SingleHostData,
(UINT16)context->SingleHostData.Size))
goto fail;
}

View File

@ -38,16 +38,12 @@
#include "../../log.h"
#define TAG WINPR_TAG("sspi.NTLM")
const char LM_MAGIC[] = "KGS!@#$%";
static const char LM_MAGIC[] = "KGS!@#$%";
static const char NTLM_CLIENT_SIGN_MAGIC[] =
"session key to client-to-server signing key magic constant";
static const char NTLM_SERVER_SIGN_MAGIC[] =
"session key to server-to-client signing key magic constant";
static const char NTLM_CLIENT_SEAL_MAGIC[] =
"session key to client-to-server sealing key magic constant";
static const char NTLM_SERVER_SEAL_MAGIC[] =
"session key to server-to-client sealing key magic constant";
static char NTLM_CLIENT_SIGN_MAGIC[] = "session key to client-to-server signing key magic constant";
static char NTLM_SERVER_SIGN_MAGIC[] = "session key to server-to-client signing key magic constant";
static char NTLM_CLIENT_SEAL_MAGIC[] = "session key to client-to-server sealing key magic constant";
static char NTLM_SERVER_SEAL_MAGIC[] = "session key to server-to-client sealing key magic constant";
static const BYTE NTLM_NULL_BUFFER[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
@ -139,7 +135,7 @@ static int ntlm_read_ntlm_v2_client_challenge(wStream* s, NTLMv2_CLIENT_CHALLENG
if (size > UINT32_MAX)
return -1;
challenge->cbAvPairs = size;
challenge->cbAvPairs = (UINT32)size;
challenge->AvPairs = (NTLM_AV_PAIR*)malloc(challenge->cbAvPairs);
if (!challenge->AvPairs)
@ -256,34 +252,35 @@ static int ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash)
WLog_ERR(TAG, "Error: Could not find user in SAM database");
return 0;
}
SamClose(sam);
return 1;
}
static int ntlm_convert_password_hash(NTLM_CONTEXT* context, BYTE* hash)
{
int status;
int i, hn, ln;
int i;
char* PasswordHash = NULL;
UINT32 PasswordHashLength = 0;
INT64 PasswordHashLength = 0;
SSPI_CREDENTIALS* credentials = context->credentials;
/* Password contains a password hash of length (PasswordLength -
* SSPI_CREDENTIALS_HASH_LENGTH_OFFSET) */
PasswordHashLength = credentials->identity.PasswordLength - SSPI_CREDENTIALS_HASH_LENGTH_OFFSET;
WINPR_ASSERT(PasswordHashLength >= 0);
WINPR_ASSERT(PasswordHashLength <= INT_MAX);
status = ConvertFromUnicode(CP_UTF8, 0, (LPCWSTR)credentials->identity.Password,
PasswordHashLength, &PasswordHash, 0, NULL, NULL);
(int)PasswordHashLength, &PasswordHash, 0, NULL, NULL);
if (status <= 0)
return -1;
CharUpperBuffA(PasswordHash, PasswordHashLength);
CharUpperBuffA(PasswordHash, (DWORD)PasswordHashLength);
for (i = 0; i < 32; i += 2)
{
hn = PasswordHash[i] > '9' ? PasswordHash[i] - 'A' + 10 : PasswordHash[i] - '0';
ln = PasswordHash[i + 1] > '9' ? PasswordHash[i + 1] - 'A' + 10 : PasswordHash[i + 1] - '0';
hash[i / 2] = (hn << 4) | ln;
BYTE hn =
(BYTE)(PasswordHash[i] > '9' ? PasswordHash[i] - 'A' + 10 : PasswordHash[i] - '0');
BYTE ln = (BYTE)(PasswordHash[i + 1] > '9' ? PasswordHash[i + 1] - 'A' + 10
: PasswordHash[i + 1] - '0');
hash[i / 2] = (BYTE)((hn << 4) | ln);
}
free(PasswordHash);
@ -488,7 +485,7 @@ exit:
* @param ciphertext cipher text
*/
void ntlm_rc4k(BYTE* key, int length, BYTE* plaintext, BYTE* ciphertext)
void ntlm_rc4k(BYTE* key, size_t length, BYTE* plaintext, BYTE* ciphertext)
{
WINPR_RC4_CTX* rc4 = winpr_RC4_New(key, 16);
@ -597,10 +594,10 @@ void ntlm_decrypt_random_session_key(NTLM_CONTEXT* context)
* @param signing_key Destination signing key
*/
static int ntlm_generate_signing_key(BYTE* exported_session_key, PSecBuffer sign_magic,
static int ntlm_generate_signing_key(BYTE* exported_session_key, const SecBuffer* sign_magic,
BYTE* signing_key)
{
int length;
size_t length;
BYTE* value;
length = WINPR_MD5_DIGEST_LENGTH + sign_magic->cbBuffer;
value = (BYTE*)malloc(length);
@ -630,9 +627,7 @@ static int ntlm_generate_signing_key(BYTE* exported_session_key, PSecBuffer sign
void ntlm_generate_client_signing_key(NTLM_CONTEXT* context)
{
SecBuffer signMagic;
signMagic.pvBuffer = (void*)NTLM_CLIENT_SIGN_MAGIC;
signMagic.cbBuffer = sizeof(NTLM_CLIENT_SIGN_MAGIC);
const SecBuffer signMagic = { sizeof(NTLM_CLIENT_SIGN_MAGIC), 0, NTLM_CLIENT_SIGN_MAGIC };
ntlm_generate_signing_key(context->ExportedSessionKey, &signMagic, context->ClientSigningKey);
}
@ -644,9 +639,7 @@ void ntlm_generate_client_signing_key(NTLM_CONTEXT* context)
void ntlm_generate_server_signing_key(NTLM_CONTEXT* context)
{
SecBuffer signMagic;
signMagic.pvBuffer = (void*)NTLM_SERVER_SIGN_MAGIC;
signMagic.cbBuffer = sizeof(NTLM_SERVER_SIGN_MAGIC);
const SecBuffer signMagic = { sizeof(NTLM_SERVER_SIGN_MAGIC), 0, NTLM_SERVER_SIGN_MAGIC };
ntlm_generate_signing_key(context->ExportedSessionKey, &signMagic, context->ServerSigningKey);
}
@ -691,9 +684,7 @@ static int ntlm_generate_sealing_key(BYTE* exported_session_key, PSecBuffer seal
void ntlm_generate_client_sealing_key(NTLM_CONTEXT* context)
{
SecBuffer sealMagic;
sealMagic.pvBuffer = (void*)NTLM_CLIENT_SEAL_MAGIC;
sealMagic.cbBuffer = sizeof(NTLM_CLIENT_SEAL_MAGIC);
const SecBuffer sealMagic = { sizeof(NTLM_CLIENT_SEAL_MAGIC), 0, NTLM_CLIENT_SEAL_MAGIC };
ntlm_generate_signing_key(context->ExportedSessionKey, &sealMagic, context->ClientSealingKey);
}
@ -705,9 +696,7 @@ void ntlm_generate_client_sealing_key(NTLM_CONTEXT* context)
void ntlm_generate_server_sealing_key(NTLM_CONTEXT* context)
{
SecBuffer sealMagic;
sealMagic.pvBuffer = (void*)NTLM_SERVER_SEAL_MAGIC;
sealMagic.cbBuffer = sizeof(NTLM_SERVER_SEAL_MAGIC);
const SecBuffer sealMagic = { sizeof(NTLM_SERVER_SEAL_MAGIC), 0, NTLM_SERVER_SEAL_MAGIC };
ntlm_generate_signing_key(context->ExportedSessionKey, &sealMagic, context->ServerSealingKey);
}

View File

@ -41,7 +41,7 @@ void ntlm_generate_timestamp(NTLM_CONTEXT* context);
int ntlm_compute_lm_v2_response(NTLM_CONTEXT* context);
int ntlm_compute_ntlm_v2_response(NTLM_CONTEXT* context);
void ntlm_rc4k(BYTE* key, int length, BYTE* plaintext, BYTE* ciphertext);
void ntlm_rc4k(BYTE* key, size_t length, BYTE* plaintext, BYTE* ciphertext);
void ntlm_generate_client_challenge(NTLM_CONTEXT* context);
void ntlm_generate_server_challenge(NTLM_CONTEXT* context);
void ntlm_generate_key_exchange_key(NTLM_CONTEXT* context);

View File

@ -0,0 +1,29 @@
/**
* WinPR: Windows Portable Runtime
* NTLM Security Package
*
* Copyright 2021 Armin Novak <armin.novak@thincast.com>
* Copyright 2021 Thincast Technologies GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WINPR_SSPI_NTLM_EXPORT_H
#define WINPR_SSPI_NTLM_EXPORT_H
extern const SecPkgInfoA NTLM_SecPkgInfoA;
extern const SecPkgInfoW NTLM_SecPkgInfoW;
extern const SecurityFunctionTableA NTLM_SecurityFunctionTableA;
extern const SecurityFunctionTableW NTLM_SecurityFunctionTableW;
#endif

View File

@ -262,9 +262,10 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf
}
length = Stream_GetPosition(s);
buffer->cbBuffer = length;
WINPR_ASSERT(length <= ULONG_MAX);
buffer->cbBuffer = (ULONG)length;
if (!sspi_SecBufferAlloc(&context->NegotiateMessage, length))
if (!sspi_SecBufferAlloc(&context->NegotiateMessage, (ULONG)length))
{
Stream_Free(s, FALSE);
return SEC_E_INTERNAL_ERROR;
@ -342,9 +343,10 @@ SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer bu
ntlm_write_version_info(s, &(message->Version));
length = Stream_GetPosition(s);
buffer->cbBuffer = length;
WINPR_ASSERT(length <= ULONG_MAX);
buffer->cbBuffer = (ULONG)length;
if (!sspi_SecBufferAlloc(&context->NegotiateMessage, length))
if (!sspi_SecBufferAlloc(&context->NegotiateMessage, (ULONG)length))
{
Stream_Free(s, FALSE);
return SEC_E_INTERNAL_ERROR;
@ -462,7 +464,7 @@ SECURITY_STATUS ntlm_read_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer buf
if (length > buffer->cbBuffer)
goto fail;
if (!sspi_SecBufferAlloc(&context->ChallengeMessage, length))
if (!sspi_SecBufferAlloc(&context->ChallengeMessage, (ULONG)length))
goto fail;
if (context->ChallengeMessage.pvBuffer)
@ -621,9 +623,10 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, PSecBuffer bu
ntlm_write_message_fields_buffer(s, &(message->TargetInfo));
length = Stream_GetPosition(s);
buffer->cbBuffer = length;
WINPR_ASSERT(length <= ULONG_MAX);
buffer->cbBuffer = (ULONG)length;
if (!sspi_SecBufferAlloc(&context->ChallengeMessage, length))
if (!sspi_SecBufferAlloc(&context->ChallengeMessage, (ULONG)length))
{
Stream_Free(s, FALSE);
return SEC_E_INTERNAL_ERROR;
@ -654,7 +657,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
size_t length;
UINT32 flags = 0;
NTLM_AV_PAIR* AvFlags = NULL;
UINT32 PayloadBufferOffset;
size_t PayloadBufferOffset;
NTLM_AUTHENTICATE_MESSAGE* message;
SSPI_CREDENTIALS* credentials = context->credentials;
@ -773,12 +776,13 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
}
length = Stream_GetPosition(s);
WINPR_ASSERT(length <= ULONG_MAX);
if (!sspi_SecBufferAlloc(&context->AuthenticateMessage, length))
if (!sspi_SecBufferAlloc(&context->AuthenticateMessage, (ULONG)length))
goto fail;
CopyMemory(context->AuthenticateMessage.pvBuffer, Stream_Buffer(s), length);
buffer->cbBuffer = length;
buffer->cbBuffer = (ULONG)length;
Stream_SetPosition(s, PayloadBufferOffset);
if (flags & MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK)
@ -986,15 +990,16 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer
s, &(message->EncryptedRandomSessionKey)); /* EncryptedRandomSessionKey */
length = Stream_GetPosition(s);
WINPR_ASSERT(length <= ULONG_MAX);
if (!sspi_SecBufferAlloc(&context->AuthenticateMessage, length))
if (!sspi_SecBufferAlloc(&context->AuthenticateMessage, (ULONG)length))
{
Stream_Free(s, FALSE);
return SEC_E_INTERNAL_ERROR;
}
CopyMemory(context->AuthenticateMessage.pvBuffer, Stream_Buffer(s), length);
buffer->cbBuffer = length;
buffer->cbBuffer = (ULONG)length;
if (context->UseMIC)
{

View File

@ -72,14 +72,14 @@ static void negotiate_SetSubPackage(NEGOTIATE_CONTEXT* context, const TCHAR* nam
{
if (_tcsnccmp(name, KERBEROS_SSP_NAME, ARRAYSIZE(KERBEROS_SSP_NAME)) == 0)
{
context->sspiA = (SecurityFunctionTableA*)&KERBEROS_SecurityFunctionTableA;
context->sspiW = (SecurityFunctionTableW*)&KERBEROS_SecurityFunctionTableW;
context->sspiA = (const SecurityFunctionTableA*)&KERBEROS_SecurityFunctionTableA;
context->sspiW = (const SecurityFunctionTableW*)&KERBEROS_SecurityFunctionTableW;
context->kerberos = TRUE;
}
else
{
context->sspiA = (SecurityFunctionTableA*)&NTLM_SecurityFunctionTableA;
context->sspiW = (SecurityFunctionTableW*)&NTLM_SecurityFunctionTableW;
context->sspiA = (const SecurityFunctionTableA*)&NTLM_SecurityFunctionTableA;
context->sspiW = (const SecurityFunctionTableW*)&NTLM_SecurityFunctionTableW;
context->kerberos = FALSE;
}
}

View File

@ -45,8 +45,8 @@ struct _NEGOTIATE_CONTEXT
CtxtHandle SubContext;
BOOL kerberos;
SecurityFunctionTableA* sspiA;
SecurityFunctionTableW* sspiW;
const SecurityFunctionTableA* sspiA;
const SecurityFunctionTableW* sspiW;
};
typedef struct _NEGOTIATE_CONTEXT NEGOTIATE_CONTEXT;

View File

@ -38,10 +38,7 @@
/* Authentication Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa374731/ */
extern const SecPkgInfoA NTLM_SecPkgInfoA;
extern const SecPkgInfoW NTLM_SecPkgInfoW;
extern const SecurityFunctionTableA NTLM_SecurityFunctionTableA;
extern const SecurityFunctionTableW NTLM_SecurityFunctionTableW;
#include "NTLM/ntlm_export.h"
extern const SecPkgInfoA KERBEROS_SecPkgInfoA;
extern const SecPkgInfoW KERBEROS_SecPkgInfoW;

View File

@ -285,7 +285,7 @@ int ArrayList_Add(wArrayList* arrayList, const void* obj)
WINPR_ASSERT(arrayList);
if (!ArrayList_Append(arrayList, obj))
return -1;
return ArrayList_Count(arrayList) - 1;
return (int)ArrayList_Count(arrayList) - 1;
}
/**

View File

@ -22,6 +22,7 @@
#endif
#include <winpr/ntlm.h>
#include <winpr/assert.h>
#include <winpr/crt.h>
#include <winpr/crypto.h>
@ -55,7 +56,8 @@ BOOL NTOWFv1A(LPSTR Password, UINT32 PasswordLength, BYTE* NtHash)
if (!(PasswordW = (LPWSTR)calloc(PasswordLength, 2)))
return FALSE;
MultiByteToWideChar(CP_ACP, 0, Password, PasswordLength, PasswordW, PasswordLength);
WINPR_ASSERT(PasswordLength <= INT_MAX);
MultiByteToWideChar(CP_ACP, 0, Password, (int)PasswordLength, PasswordW, (int)PasswordLength);
if (!NTOWFv1W(PasswordW, PasswordLength * 2, NtHash))
goto out_fail;
@ -105,9 +107,12 @@ BOOL NTOWFv2A(LPSTR Password, UINT32 PasswordLength, LPSTR User, UINT32 UserLeng
if (!UserW || !DomainW || !PasswordW)
goto out_fail;
MultiByteToWideChar(CP_ACP, 0, User, UserLength, UserW, UserLength);
MultiByteToWideChar(CP_ACP, 0, Domain, DomainLength, DomainW, DomainLength);
MultiByteToWideChar(CP_ACP, 0, Password, PasswordLength, PasswordW, PasswordLength);
WINPR_ASSERT(UserLength <= INT_MAX);
WINPR_ASSERT(DomainLength <= INT_MAX);
WINPR_ASSERT(PasswordLength <= INT_MAX);
MultiByteToWideChar(CP_ACP, 0, User, (int)UserLength, UserW, (int)UserLength);
MultiByteToWideChar(CP_ACP, 0, Domain, (int)DomainLength, DomainW, (int)DomainLength);
MultiByteToWideChar(CP_ACP, 0, Password, (int)PasswordLength, PasswordW, (int)PasswordLength);
if (!NTOWFv2W(PasswordW, PasswordLength * 2, UserW, UserLength * 2, DomainW, DomainLength * 2,
NtHash))
@ -170,8 +175,10 @@ BOOL NTOWFv2FromHashA(BYTE* NtHashV1, LPSTR User, UINT32 UserLength, LPSTR Domai
if (!UserW || !DomainW)
goto out_fail;
MultiByteToWideChar(CP_ACP, 0, User, UserLength, UserW, UserLength);
MultiByteToWideChar(CP_ACP, 0, Domain, DomainLength, DomainW, DomainLength);
WINPR_ASSERT(UserLength <= INT_MAX);
WINPR_ASSERT(DomainLength <= INT_MAX);
MultiByteToWideChar(CP_ACP, 0, User, (int)UserLength, UserW, (int)UserLength);
MultiByteToWideChar(CP_ACP, 0, Domain, (int)DomainLength, DomainW, (int)DomainLength);
if (!NTOWFv2FromHashW(NtHashV1, UserW, UserLength * 2, DomainW, DomainLength * 2, NtHash))
goto out_fail;